开发者

Unit tests must locate in the same package?

A JUnit book says " protected method 开发者_如何学C... 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)?


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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜