Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you organize unit tests into packages?

As a matter of fact you have smth like /java/src and /java/test. But then, how do you name packages/classes the unittests go to? The same as classes they are written against? And when refactoring comes, do you manually rename in /test? Please share your experience.

like image 775
yanchenko Avatar asked Oct 11 '08 05:10

yanchenko


People also ask

How are junit tests organized?

The easiest way to organize your tests is to place them directly alongside your production code, in the same package and source tree. If you do this, all the code you need to compile is in one directory structure, simplifying your build process.

Where do unit tests go in python project?

If your package and test code are small and self contained, put the tests in with the package. If the tests are large or complex, or require reading/writing files, or significant sample data, put your tests outside the package.


1 Answers

I keep the tests in the same package as the class they are testing. This allows me to setup tests using package private members (when required). It also provides a nice, easy to remember convention. When I refactor, I usually do manually refactor the corresponding test classes. There was some IDE a while back that had the ability to do this refactoring automatically, but I can't remember it off the top of my head.

like image 108
Daniel Spiewak Avatar answered Oct 06 '22 19:10

Daniel Spiewak