I'm getting back into Java after a long stint in the Ruby world and I've got a question about JUnit tests and the source I'm testing.
If I've got a package of graphics code for my company, lets call it com.example.graphics
, should I include my tests in that package too or should they be included in a seperate package, like com.example.graphics.test
?
In the same java package is fine. It's actually necessary if you need to access package-private classes, methods, or fields. However, the source should be logically separate:
src/main/com/example/graphics
src/test/com/example/graphics
If you do not need to access private classes it is actually a question of flavor.
I sometimes even tend to create an additional test-project referenced to the product-project. Therefore, product and test are clearly seperated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With