首先,从下面地址下载jdk-8u121-windows-x64.exe
https://github.com/lkws/triangleproblemTest.git
安装jdk环境,请参考网上教程
第二,在eclipse上创建新的Java工程项目
从下面地址下载hamcrest-core-1.3.jar、hamcrest-library-1.3.jar、junit-4.12.jar并在eclipse上导入(导入方法自行百度)
https://github.com/lkws/triangleproblemTest.git
编写triangleproblem代码如下
使用Junit4测试,自动生成triproTest.java文件,添加测试用例如下
开始测试,测试结果如图
在triproTest.java文件空白处右键-->Coverage As -->1 JUnit Test进行代码覆盖率测试,测试结果如下
Done!