首页 > 代码库 > Software Testing lab01
Software Testing lab01
1.下载junit和hamcrest的jar包并引入项目
2.在eclipse商店中下载安装eclemma插件
3.编写判断三角形形状的代码
package lab1source; public class src1 { public static String T(double a,double b,double c){ double tem = Math.max(a, b); if(tem>c){ if(tem==a){ a = c; }else { b = c; } c = tem; } if(!(a+b>c&&Math.abs(a-b)<c)){ return "not a triangle"; }else if(a==b && a==c){ return "equilateral triangle"; }else if(a==b || a==c || b==c){ return "isosceles triangle"; }else return "scalene triangle"; } public static void main(String[] args) { System.out.println(src1.T(3, 3, 3)); } }
4.完成测试类代码
package lab1source; import static org.junit.Assert.*; import org.junit.Test; public class src1Test { src1 s1= new src1(); @Test public void testT() { assertEquals("equilateral triangle",s1.T(3,3,3)); assertEquals("isosceles triangle",s1.T(3,4,3)); assertEquals("scalene triangle",s1.T(3,4,5)); } }
5.测试结果
Software Testing lab01
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。