junit对程序进行测试

来源:互联网 发布:3d数据库 编辑:程序博客网 时间:2024/04/29 15:58
public class Person {public void run(){System.out.println("run!");}public void eat(){System.out.println("eat!");}}

有2个方法,再建一个类

import org.junit.Test;public class TestDome {@Testpublic void testRun(){Person p = new Person();p.run();}@Testpublic void testEun(){Person p = new Person();p.eat();}}

可以运行进行测试

其中也能加些Assert(断言),进行测试



0 0