环境搭建过程:
JUnit4是Eclipse中自带的,eclemma的安装也是在Eclipse中完成,选择help菜单中的Eclipse Marketspace选项,搜索eclemma进行安装。
测试过程:
使用5个测试用例:
triangle = new Triangle(1,1,1);assertEquals(0, triangle.identify());//equilateraltriangle = new Triangle(-1,1,1);assertEquals(-1, triangle.identify());//input wrongtriangle = new Triangle(1,2,3);assertEquals(-1, triangle.identify());//input wrongtriangle = new Triangle(2,2,3);assertEquals(1, triangle.identify());//isoscelestriangle = new Triangle(2,3,4);assertEquals(2, triangle.identify());//scalene
测试结果与覆盖率如图所示:
github地址: