views:

77

answers:

2

A JUnit book says " protected method ... this is one reason the test classes are located in the same package as the classes they are testing"

Can someone share their experience on how to organize the unit tests and integration tests (package/directory wise)?

+8  A: 

in my build process, the source directories are

java/src
java/test/unit
java/test/integration

The test and the source code are in different paths, but the packages are the same

java/src/com/mypackage/domain/Foo.java
java/test/unit/com/mypackage/domain/FooTest.java
java/test/integration/com/mypackage/domain/FooTest.java
Aaron Saunders
thanks, that helps
sean
+7  A: 

I prefer the maven directory layout. It helps you separate the test sources and test resources from your application sources in a nice way and still allow them to be part of the same package.

I use this for both maven and ant based projects.

  project
    |
    +- src
        |
        +- main
        |    |
        |    +- java // com.company.packge (sources)
        |    +- resources
        |
        +- test
             |
             +- java // com.company.package (tests)
             +- resources
naikus