如何对Java中分类的私有(具有包可见性的单元)进行单元测试?
How to unit test private (means with package visibility) classed in java?
我有一个程序包,此程序包中只有一个类是公共的,其他类是私有的.如何用单元测试覆盖其他分类?我想在休息罐中加入单元测试.
I have a package, only one class is public in this package, other classes are private. How to cover other classed with unit tests? I would like to include unit tests in resting jar.
推荐答案在同一包中创建单元测试类.
Create the unit test class in the same package.
例如,如果com.example.MyPrivateClass位于src/main/java/com/example/MyPrivateClass.java
然后测试类将位于相同的程序包com.example.MyPrivateClassTestCase中,并将位于src/test/java/com/example/MyPrivateClassTestCase.java
Then the test class will be in same package com.example.MyPrivateClassTestCase and will be located in src/test/java/com/example/MyPrivateClassTestCase.java
更多推荐
私人班级单元测试
发布评论