软件测试Lab1--对单元测试中的 Junit、Hamcrest 和 Eclemma 的安装、理解及使用

一、实验要求

  1. Install Junit(4.12), Hamcrest(1.3) with Eclipse
  2. Install Eclemma with Eclipse
  3. Write a java program for the triangle problem and test the program with Junit.
    a)Description of triangle problem:
    Function triangle takes three integers a,b,c which are length of triangle sides; calculates whether the triangle is equilateral, isosceles, or scalene.

二、实验过程
1、安装 Junit 与 hamcrest
(1)百度 Junit 和 Hamcrest 的 Jar 包,下载。
(2)在 Eclipse 中新建一个 Java-project,右键点击这个项目,依次选择 Properties->Java Build Path->Libraries,点击“Add External JARs”按钮后选中刚刚下载的 Junit 和 Hamcrest 的 Jar 包即可。

2、安装 Eclemma
在 Eclipse 中选择 Help->Eclipse Marketplace,然后搜索 EclEmma,并点击 Install 进行安装。

(此图为已经安装成功的状态)
3、实现程序
(1)在 src 目录下新建名为 com.triangle 的 package,然后在 package 新建名为 Triangle.java 和 TriangleTest.java 的源文件。
(2)代码如下:

4、测试用例
代码如下:

5、测试运行

 绿色表示被执行到,黄色表示部分执行,红色表示没有被执行。


绿色表示测试通过,红色表示测试失败。

每一个test的显示时间。

覆盖率。
posted @ 2017-03-16 12:59  裴顺达  阅读(148)  评论(0编辑  收藏  举报