1. Installing

 1. Install Junit and hamcrest

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

Then. I add them into eclipse library

After installing,

   2. Installing eclemma

Installing with Eclipse Marketplace

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

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.

The last is Coverage Testing with Eclemma

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

  1. Software Testing Techniques LAB 02: 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(By Ron Patton)

    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 (LFI) Testing Techniques

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

  7. 101+ 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.3.7 -------Introduction to Software Testing (Paul Ammann and Jeff Offutt)

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

随机推荐

  1. ZendStudio操作技巧

    1.恢复窗口默认布局 点开菜单栏上的“windows”,出来的菜单中有个“Reset Perspective...”,点这个就行了

  2. 第3章—高级装配—配置profile bean

    配置profile bean 3.1.@profile注解是spring提供的一个用来标明当前运行环境的注解. 我们正常开发的过程中经常遇到的问题是,开发环境是一套环境,qa测试是一套环境,线上部署又 ...

  3. Couchbase进阶-集群与版本升级

    最近在负责公司Couchbase版本升级工作,之前只有一台Cache服务器,使用Couchbase Enterprise Edition 1.8,为避免单点故障现在需要新增加一台Cache服务器做负载 ...

  4. 【es6】正则扩展

  5. WebDriver获得表格里所有单元格的文本

    方法为: 1. 得到表格中所有的tr,存到list到中 2.对tr进行循环,根据当前的tr,得到当前所有td的集合存到list当中 3.循环中所有td里的文本 package com.example. ...

  6. SPSS学习系列之SPSS Statistics的菜单栏介绍(图文详解)

    不多说,直接上干货! 以下是菜单栏 1.以下是文件栏: 2.以下是编辑栏 3.以下是查看栏   4.以下是数据栏: 5.以下是转换栏: 6.以下是分析栏: 7.以下是直销栏: 8.以下是图形栏: 9. ...

  7. 2016年学习JavaScript是怎样的一种体验(转)

    转自:http://www.zcfy.cc/article/how-it-feels-to-learn-javascript-in-2016-hacker-noon-1871.html 在这篇文章的写 ...

  8. JS+Zero Clipboard swf复制到剪贴板 兼容浏览器(bind事件绑定函数)

    转自http://www.ipmtea.net/css_ie_firefox/201107/07_499.html 1.ZeroClipboard其实是国外的一个js类库,源码结构如: var Zer ...

  9. canvas的measureText()方法

    做一个小动画的时候遇到了个问题,就是在给文字应用渐变色的时候,不知怎么设置渐变色的区域. 渐变依赖于定义时的区域,超出这个区域只有纯色,而不是渐变色. 所以要取得文字的宽度. 查了资料得知,canva ...

  10. Oracle中的自连接(self join)-当表中的某一个字段与这个表中另外字段的相关时,我们可能用到自连接。

    http://blog.163.com/wkyuyang_001/blog/static/10802122820091751049479/ 当表中的某一个字段与这个表中另外字段的相关时,我们可能用到自 ...