1. 先下载这个包
解压文件到eclipse安装路径下面的pluginss文件夹下面
F:\\javaeclispe\\eclipse\\plugins 然后重启eclipse软件
创建一个工程
Test.java packagecom.by.test; publicclass Test { //随便写一个方法 publicint test(inta,intb) { returna+b; } }
TestClass.java packagecom.by.test; importjunit.framework.TestCase; publicclassTestClassextendsTestCase { private Test t = null; protectedvoidsetUp() throws Exception { // 初始化信息的方法 t = new Test(); } protectedvoidtearDown() throws Exception { super.tearDown(); } // 一个测试的方法 publicvoid testMethod1() { // 这个就是来测试Test类里面的方法的方法 // 断言的那个关键字assert assertEquals(t.test(1, 1), 2); // 1+1=2这是正确的 } }
因篇幅问题不能全部显示,请点此查看更多更全内容