博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
软件测试实验一
阅读量:4632 次
发布时间:2019-06-09

本文共 1821 字,大约阅读时间需要 6 分钟。

实验报告

a) The brief description that I install junit, hamcrest and eclemma.

Junit,hamcrest

上网下载junit,hamrest包,然后在项目中新建文件夹lib,复制包到其中,然后单击项目->build path -> configer build path,然后在把包加入,如图

 Eclemma

解压 eclemma压缩包,将其复制于eclipse->dropins文件夹下。删除META-INF文件夹。

b) The test result and coverage report (print screen) of your tests on triangle problem. 

代码:

package homeWork1;

public class Triangle {

public boolean lengthTest(int a , int b, int c){
if ( a + b > c && a + c > b && b + c > a){
return true;
}else{
return false;
}
}
public boolean isPositive(int a , int b , int c){
boolean ans = true;
if (a <= 0 || b <= 0 || c <=0 ){
ans = false;
//System.out.println("The number of edge must be a positive number");
}
return ans;
}
public boolean isTriangle(int a, int b , int c){
if(isPositive(a,b,c)){
if(lengthTest(a,b,c)){
return true;
}else{
//System.out.println("It can't be a triangle.");
return false;
}
}else{
return false;
}
}
public String function(int a, int b, int c){
if(isTriangle(a,b,c)){
if (a == b && b == c){
return "equilateral";
}else if(a == b || b == c || a == c){
return "isosceles";
}else{
return "scalene";
}
}else{
return "noTriangle";
}
}

}

测试代码;

package homeWork1;

import static org.junit.Assert.assertEquals;

import org.junit.After;

import org.junit.Before;
import org.junit.Test;

public class TriangleTest {

Triangle t1 = new Triangle();
public void test(){
assertEquals("noTriangle",t1.function(-1, 2, 3));
assertEquals("noTriangle",t1.function(1, 2, 3));
assertEquals("noTriangle",t1.function(8, 2, 3));
assertEquals("equilateral",t1.function(3, 3, 3));
assertEquals("isosceles",t1.function(3, 3, 2));
assertEquals("scalene",t1.function(3, 4, 2));
}
public static void main(String[] args) {
TriangleTest t2 = new TriangleTest();
t2.test();
}
}

 

覆盖结果:

 

转载于:https://www.cnblogs.com/hzj3015218059/p/8647381.html

你可能感兴趣的文章
C - 娜娜梦游仙境系列——吃不完的糖果
查看>>
巴黎公社社员造船厂Project1129研制成功
查看>>
poj2007极角排序
查看>>
POJ 1204 Word Puzzles
查看>>
JEESZ分布式框架--单点登录集成方案
查看>>
三元表达式,列表生成式,字典生成式,生成器表达式
查看>>
.net core集成 vue
查看>>
ZOJ3829---模拟,贪心
查看>>
Windows XP系列全下载(均为MSDN原版)
查看>>
如何提高ASP.NET性能
查看>>
vh属性-- 一个永远垂直居中的弹出框
查看>>
LAMP集群项目三 配置业务服务器
查看>>
《Unity_API解析》 第五章 Mathf类
查看>>
计算器
查看>>
批处理备份
查看>>
To the Max(矩阵压缩)
查看>>
数组的学习+冒泡排序
查看>>
C程序设计语言----第1章 导言(一)
查看>>
asp.net文件下载
查看>>
APK IPA --------------- iis7如何添加mime类型支持所有后缀名文件下载的方法(解决特殊后缀文件无法下载的问题)...
查看>>