Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Organization of JUnit tests in projects

Tags:

java

junit

What would you consider best practice for organizing JUnit tests in a project, and why? For example, do you keep your tests next to the classes they test? Do you put them in a separate but parallel package structure? Do you use a different organization strategy entirely?

like image 662
Robert J. Walker Avatar asked Oct 08 '08 16:10

Robert J. Walker


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.


1 Answers

I use a separate but parallel package structure for several reasons.

  1. It keeps tests organized the same way as the application code.
  2. I can easily build just the application files for distribution.
  3. Test code still has access to my application code.
  4. It's not as cluttered as having test code mixed with application code.
like image 91
Bill the Lizard Avatar answered Sep 19 '22 03:09

Bill the Lizard