私人班级单元测试

编程入门 行业动态 更新时间:2024-10-24 22:26:46
本文介绍了私人班级单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

更多推荐

私人班级单元测试

本文发布于:2023-10-31 05:55:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545206.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:班级   单元测试   私人

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!