软件测试实验一

Lab 1 Junit and 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.

 

二.  实验步骤:

(一)导入Junit(4.12), Hamcrest(1.3):

  1. 在办公网上下载老师提供的Junit(4.12).jar, Hamcrest(1.3).jar。
  2. 我使用的MacBook,所以使用IDEA编程方便些,打开IDEA,点击File,然后点击Project Structure.

 file:///Users/Cherie_Wang/Desktop/屏幕快照%202016-03-18%20上午11.51.14.png

  1. 点击右侧library添加两个.jar包。

file:///Users/Cherie_Wang/Desktop/屏幕快照%202016-03-18%20上午11.51.49.png 

(二)导入Eclemma:

因为使用的IDEA自带程序覆盖,无需安装Eclemma。

(三)程序设计:

因为老师的实验要求是要判断是否为等边三角形、等腰三角形以及三边不等的三角形,所以我的程序也只考虑了三种情况,而且只采用了整型进行测试,未考虑double型。能够满足题意。

(四)实验测试结果及程序覆盖图:

 

file:///Users/Cherie_Wang/Desktop/屏幕快照%202016-03-18%20上午11.46.29.png 

 

file:///Users/Cherie_Wang/Desktop/屏幕快照%202016-03-18%20上午11.48.57.png 

 file:///Users/Cherie_Wang/Desktop/屏幕快照%202016-03-18%20上午11.47.27.png

 

三.    实验结论:

测试结果符合实际,程序覆盖率为80%。

原文地址:https://www.cnblogs.com/MelodyWang/p/5292274.html