[软件测试_LAB1]安装junit和hamcrest及其使用

一、在IDE中集成junit和hamcrest

创建工程后,导入junit和hamcrest的jar包

hamcrest-all-1.3.jar

junit-4.12.jar

使用的IDE为Intellij IDEA,在项目上右键,打开Open Module Settings,在Library选项卡中添加以上两个jar包,即可在程序中使用

二、创建判断三角形的Triangle类

三、创建相应的测试类

目录结构如下

四、运行测试用例

测试通过

五、查看代码覆盖率

通过点击Run 'TriangleTest with Coverage' 进行代码覆盖率测试,结果如下

原文地址:https://www.cnblogs.com/gaomengya/p/5291519.html