开发者

JUnit testing package private class in Maven formatted project

开发者 https://www.devze.com 2023-04-11 11:20 出处:网络
I have a package private implementation of an Interface, the methods defined in that Interface can be accessed through a public factory. I was just wonderin开发者_开发技巧g, how should I unit test tha

I have a package private implementation of an Interface, the methods defined in that Interface can be accessed through a public factory. I was just wonderin开发者_开发技巧g, how should I unit test that class as it cannot be accessed outside the package, or should I be testing it through the factory?

Thanks

-Abidi


The usual convention is to put the unit test of a class in the same package as the class under test. This allows the unit test to access package-private and protected methods of the class, and thus to test them.

0

精彩评论

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