public class HelloWorld
{
public String say()
{
return("Hello World!");
}
public int add(int a,int b)
{
return a+b;
}
}
2.书写测试的类
//测试helloworld.java类
package bank;
import junit.framework.TestCase;
public class HelloWorldTest extends TestCase {
public HelloWorldTest(String name)
{
super(name);
}
public void testSay() {
HelloWorld hi = new HelloWorld();
// assertEquals("Hello World!", hi.say());
TestCase.assertEquals(3, hi.add(1,2));
}
public static void main(String[] args) {
junit.textui.TestRunner.run(
HelloWorldTest.class);
}
}
注意这里,选中被测试类-右键-new-junit test case 这样创建!!!
还要注意的小动作是:测试类的运行RUN AS... 下的JUNIT TEST.
run ...
出现绿棒,好开心啊~ 进步很快了,不到2天入门。。。自己替自己开心
最后
以上就是明亮抽屉最近收集整理的关于java白盒测试用例_junit 白盒测试简单实例的全部内容,更多相关java白盒测试用例_junit内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复