为什么必须将Junit中的测试方法定义为公开? [英] Why should Test methods in Junit be defined public?
本文介绍了为什么必须将Junit中的测试方法定义为公开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在阅读有关junit测试的文档,但无法理解将测试定义为公共测试的必要性.任何人都可以分享一些有关此信息吗?
I was going through the documentation for junit tests but am unable to understand the need for defining tests as public.Could anyone share some info on this?
我在
但是我仍然不清楚原因.
But am still not clear with the reason.
我的意思是为什么我不能写一些东西
With is I meant why can't I write something as
@Test
private void testAdd(){ }
推荐答案
JUnit框架从测试类外部调用测试方法.如果您的测试方法是私有的,它将无法执行此操作.
The JUnit framework calls your test methods from outside your test class. If your test methods are private, it won't be able to do that.
这篇关于为什么必须将Junit中的测试方法定义为公开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文