Java: Subpackage visibility?

后端 未结 9 1459
予麋鹿
予麋鹿 2020-11-29 02:06

I have two packages in my project: odp.proj and odp.proj.test. There are certain methods that I want to be visible only to the classes in these two

9条回答
  •  攒了一身酷
    2020-11-29 02:48

    This is no special relation between odp.proj and odp.proj.test - they just happen to be named as apparently related.

    If the odp.proj.test package is simply providing tests then you can use the same package name (odp.proj). IDEs like Eclipse and Netbeans will create separate folders (src/main/java/odp/proj and src/test/java/odp/proj) with the same package name but with JUnit semantics.

    Note that these IDEs will generate tests for methods in odp.proj and create the appropriate folder for the test methods it doesn't exist.

提交回复
热议问题