junit测试类的包结构应该与功能类的包结构一致

  为对应的功能类写junit测试类时,应该使用和功能类一样的包结构。这可以从junit3.8.1中的faq中得知:

在junit3.8.1的faq中(/doc/faq/faq.htm#organize_1)这样说:

  Organizing Tests:  top 

Where should I put my test files?

You can place your tests in the same package and directory as the classes under test.

For example:

src

   com

      xyz

         SomeClass.java

         SomeClassTest.java

Or, if you feel this clutters the source directory, you can place the tests in a separate parallel directory structure with package alignment.

For example:

src

   com

      xyz

         SomeClass.java

test

   com

      xyz

         SomeClassTest.java

These approaches allow the tests to access to all the package visible methods and fields of the classes under test.

  而且,在java中,为了保持一个类在整个世界上的唯一性,使用反转域名的方案。当然测试类也应该遵守这个方案。而不是造另外的一种方案。

  以上见解若有误,还望见者给以指正。谢谢。