一、实验目的
1.下载Junit(4.12),Hamcrest(1.3),并将两个jar添加到项目中
2.写一个判断三角形形状问题的函数(等边三角形,等腰三角形,非等边三角形)
3.下载eclemma,并使用其判断程序的覆盖率
二、实验过程
1.下载junit-4.12.jar和hamcrest-all-1.3.jar两个jar包,并将两个包添加到创建路径中
Properties->Java Build Path->Libraries->Add External JARs
2.在src下创建一个package(cn.tju.scs.Triangle)并在其中建立并编写一个Calc.java用于判断三条边是否能够组成一个三角形,以及该三角形的种类
3.创建名为test的source Folder,在其中创建一个package(cn.tju.scs.Triangle)与上面同名,并编写一个calcTest.java用于测试Calc.java中的judge函数是否正确
具体结构格式如图:
4.运行程序检查结果
5.使用eclemma检查程序的覆盖率
三、实验结果
实验数据测试成功,并且覆盖率达到100%