1 Reply Latest reply: Dec 1, 2010 9:07 AM by Jesper Pedersen RSS

TestSuite - renaming and repackaging

Stefano Maestri Expert

Hi all,

 

during my refactoring of our test suite I'm wondering if we can make some renaming and repackaging of our test:

 

  • Remove .test package to have test classes in the same namespace of classes under test
  • Try to remove also unit namespace where it is there
  • We are running as Junit test only classes ending with TestCase. It is a quite usual and classic choice, but it is limiting the opportunity of selecting more self describing name for classes as for method in a BDD style. IOW it would be great to make us free of selecting not only the name of the method (for example shouldDoSomething), but also class name. In a BDD style it would be used to define more than one test stressing a class undertest, verifying in each test different aspect/behavior of class under test. Using a classic pet example we could have 2 different test for class Cat named for example as CatShouldBeAHunter (with methods shouldCatchMouses, shouldEatAnimals etc) and CatShouldBeDomesticAnaimal (with method shouldLoveMe, shouldMakeDisaster and so on ). To do that we should refactor also our build to consider every classes in the src/test as test case, apart of course some explicit exclusion. This explicit exclusion will be for support/mock class which should be put into a specific package (support or mock is a good name IMHO) and/or using a suffix in their name.
  • At the moment I'll leave every test ala TCK (i.e. org.jboss.jca.test.core.spec.chapter* packages in core module) as is. They are totally different kind of test and should not be considered as unit ones.

 

Any comment is more than welcome

 

S.

  • 1. Re: TestSuite - renaming and repackaging
    Jesper Pedersen Master

    Remove .test package to have test classes in the same namespace of classes under test

     

    Agreed. In order to better test package private methods.

     

    Try to remove also unit namespace where it is there

     

    Agreed.

     

    We are running as Junit test only classes ending with TestCase.

     

    As long as there is an easy way for developers to identify which classes are tests and which are support/mock classes. Using package names for this is a good idea. However, I don't see this as the highest priority for the new test suite.

     

    At the moment I'll leave every test ala TCK

     

    Yes, we should keep the tests described in http://docs.jboss.org/ironjacamar/developerguide/en/html/testing.html#spectest separate so specification requirements are quite clear.