Software Testing Techniques LAB 01: test Junit and Eclemma

时间:2021-12-02 23:38:03

1. Installing

 1. Install Junit and hamcrest

First, I download the Junit-4.12.jar and hamcrest-core-1.3.jar

Software Testing Techniques LAB 01: test Junit and Eclemma

Then. I add them into eclipse library

Software Testing Techniques LAB 01: test Junit and Eclemma

Software Testing Techniques LAB 01: test Junit and Eclemma

After installing,

Software Testing Techniques LAB 01: test Junit and Eclemma

   2. Installing eclemma

Installing with Eclipse Marketplace

Software Testing Techniques LAB 01: test Junit and Eclemma

2. Testing

  1. Coding

Write a java program for the triangle problem, which can calculate whether the triangle is equilateral, isosceles or scalene.

package newTest;

public class Triangle {

	public int a;
public int b;
public int c; public Triangle(){ } public Triangle(int a, int b, int c){
this.a=a;
this.b=b;
this.c=c;
} public String calculate(){ if ( a + b <= c || b + c <= a || c + a <= b ){
return "Not a triangle";
}
else if( a == b && a == c ){
return "equilateral";
}
else if( a == b || a == c || b == c ){
return "isosceles";
}
else{
return "scalene";
}
} }

2. Creating Junit test case

Software Testing Techniques LAB 01: test Junit and Eclemma

Software Testing Techniques LAB 01: test Junit and Eclemma

Then, finish the test case

package newTest;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test; public class TriangleTest { public Triangle tri; @Before
public void setUp() throws Exception {
} @Test
public void testCalculate() {
tri = new Triangle(1,1,1);
assertEquals("equilateral",tri.calculate());
tri = new Triangle(2,2,3);
assertEquals("isosceles",tri.calculate());
tri = new Triangle(2,2,1);
assertEquals("isosceles",tri.calculate());
tri = new Triangle(3,4,5);
assertEquals("scalene",tri.calculate());
tri = new Triangle(3,5,9);
assertEquals("Not a triangle",tri.calculate());
} }

3. Testing and debug

Run the Junit test case, I found some Failures, then I correct them.

Software Testing Techniques LAB 01: test Junit and Eclemma

Software Testing Techniques LAB 01: test Junit and Eclemma

Software Testing Techniques LAB 01: test Junit and Eclemma

The last is Coverage Testing with Eclemma

Software Testing Techniques LAB 01: test Junit and Eclemma

Software Testing Techniques LAB 01: test Junit and Eclemma的更多相关文章

  1. Software Testing Techniques LAB 02&colon; Selenium

    1. Installing 1. Install firefox 38.5.1 2. Install SeleniumIDE    After installing, I set the view o ...

  2. Software Testing Techniques Homework 3

    1. a.This is the chart b. initial numPrimes = 4, t1 would over the loop. c. t = ( n = 1) d. node cov ...

  3. Software Testing Techniques Homework 2

    Problem 1 1. The fault is i > 0, it should be  i >= 0, because if the case is x = [0], y= 0, w ...

  4. Software Testing Techniques Homework 1

    I have met some errors in recent years, one of them which impress me most. It happend when I try to ...

  5. 读书笔记-Software Testing&lpar;By Ron Patton&rpar;

    Software Testing Part I:The Big Picture 1.Software Testing Background Bug's formal definition 1.The ...

  6. Web Application Penetration Testing Local File Inclusion &lpar;LFI&rpar; Testing Techniques

    Web Application Penetration Testing Local File Inclusion (LFI) Testing Techniques Jan 04, 2017, Vers ...

  7. 101&plus; Manual and Automation Software Testing Interview Questions and Answers

    101+ Manual and Automation Software Testing Interview Questions and Answers http://www.softwaretesti ...

  8. Exploratory Software Testing

    最近找到去年上半年看过一本关于测试方面书籍的总结笔记,一直放在我的个人U盘里,当时是用Xmind记录的,现在重新整理下分享给大家了! James A.Whittaker [美] 詹姆斯·惠特克(软件测 ...

  9. Page 63-64 Exercises 2&period;3&period;7 -------Introduction to Software Testing &lpar;Paul Ammann and Jeff Offutt&rpar;

    Use the following method printPrimes() for question a-d below //Find and prints n prime integers pri ...

随机推荐

  1. 安装centos虚拟机

    启动虚拟机提示"无法连接虚拟设备ide1:0,主机上没有相对应的设备" 进入编辑虚拟机设置--选中硬盘--点高级--在 虚拟机设备节点中选ide0:0接行了.

  2. Fair Photography

    题目大意: 给出直线上N个点的位置和颜色(0或1),求最大的区间,使得区间内0的个数大于等于1的个数且0的个数减去1的个数为偶数. 解题过程: 1.先贴个lsdsjy大牛的线段树的做法:http:// ...

  3. java非静态变量初始化

    java费静态变量的初始化分为两种情况,一种是局部变量,一种是类的域. 对于类的域,java在类初始化时,会为变量赋一个初始值.对于基本数据类型,java会将初始值设置为二进制0,具体为将boolea ...

  4. php基础知识【函数】(6)mysql数据库

    一.连接和关闭 1.mysql_connect('example.com:3307', 'root', '123456') --打开一个到 MySQL 服务器的非永久连接 2.mysql_pconne ...

  5. weather compare

  6. Java 多线程详解(四)------生产者和消费者

    Java 多线程详解(一)------概念的引入:http://www.cnblogs.com/ysocean/p/6882988.html Java 多线程详解(二)------如何创建进程和线程: ...

  7. 卷积神经网络之VGG

    2014年,牛津大学计算机视觉组(Visual Geometry Group)和Google DeepMind公司的研究员一起研发出了新的深度卷积神经网络:VGGNet,并取得了ILSVRC2014比 ...

  8. Neutron中插件与代理的总结

    1.总结:

  9. oneinstack如何安装ssl证书和配置Let&&num;39&semi;s Encrypt免费SSL证书教程汇总(转)

    OneinStack包含以下组合:lnmp(Linux + Nginx+ MySQL+ PHP) LNMP安装SSL安全证书 部署HTTPS:https://www.gworg.com/ssl/309 ...

  10. spring ,springmvc的常用标签注解

    一:spring常用的注解: @Configuration把一个类作为一个IoC容器,它的某个方法头上如果注册了@Bean,就会作为这个Spring容器中的Bean.@Scope注解 作用域@Lazy ...