Software Tset Lab1

一、实验要求

1.使用Eclipse安装Junit(4.12),Hamcrest(1.3)

2.使用Eclipse安装Eclemma

3.为三角形问题编写一个Java程序,并用Junit测试程序。

a)三角问题的描述:

函数三角形取三个整数a,b,c,它们是三角形边的长度; 计算三角形是等边,等腰或斜角。

 

二、实验过程及结果

1、junit,hamcrest和eclemma的安装步骤。

1)从官网下载最新的junit和hamcrest的jar包。

2)在使用时,依次点击“Build path”——“Configure build path”—— “Libraries”——“Add External JARS”,将其添加到项目(操作示意如下图)

3)最后在线安装eclemma:点击“Help”——“Install new software”——输入“eclemma”搜索——勾选排在第一个的版本进行安装。之后,Eclipse会自动为我安装配置eclemma。

 

2、三角程序测试结果及覆盖报告

针对三角形,分别进行等边、等腰、非等边及非三角形的用例测试。

检验三角形代码如下:

测试代码如下:

 

实验结果显示:程序运行没有错误,且覆盖路径100%。(测试结果如下图所示)

 

 

英文版:

1.Experimental requirements

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.

 

2.Experimental process and results

 

1) junit, hamcrest and eclemma installation steps:
  (1)Downloading the latest junit and hamcrest jar package from the official website.
  (2) In use, click "Build path" - "Configure build path" - "Libraries" - "Add External JARS", add the junit and hamcrest jar packages to the project (operation shown below)

    

   (3)Finally install eclemma online in eclipse: Click "Help" - "Install new software" - type in "eclemma" and search - select the first version of eclemma to install. After that, Eclipse will automatically install eclemma for me.

 

  2)triangular test results and coverage reports
For the triangle, respectively, equilateral, isosceles, non-equilateral and non-triangular use case test.
Check the triangle code as follows:

Testing code as follows:

The experimental results show that the program runs without error,fault  or failure and covers 100% of the test path. (Test results as shown below)

 

 

 

 

 

 

 

 

posted on 2017-03-12 11:01  HuMeng96  阅读(70)  评论(0编辑  收藏  举报

导航