私人班级单元测试 [英] Private class unit tests

查看:97
本文介绍了私人班级单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何对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

这篇关于私人班级单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆