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. html-css-js基本理解和简单总结

    目录 一.对于网页的基本理解 1.网页是一种数据展示和信息交互的载体 2.网页组成部分 3.支撑一个网页的技术模块 二.html的理解和技术笔记 1.html理解 2.html技术笔记-html标签 ...

  2. Java高并发之锁优化

    本文主要讲并行优化的几种方式, 其结构如下: 锁优化 减少锁的持有时间 例如避免给整个方法加锁 public synchronized void syncMethod(){ othercode1(); ...

  3. Javac的命令(-Xlint)

    在OptionName类中的枚举定义如下: XLINT("-Xlint"), XLINT_CUSTOM("-Xlint:"), -Xlint     Enabl ...

  4. spring中redistemplate不能用通配符keys查出相应Key的问题

    有个业务中需要删除某个前缀的所有Redis缓存,于是用RedisTemplate的keys方法先查出所有合适的key,再遍历删除.但是在keys(patten+"*")时每次取出的 ...

  5. java.lang.IllegalArgumentException: Comparison method violates its general contract!

    这个错误就是写比较器的时候少写了返回值的情况: 比如: Collections.sort(list, new Ordering<QtmSysUserListDto>() { @Overri ...

  6. 有符号整数比较v.s.无符号整数比较

    本文尝试从汇编的角度给出有符号整数比较与无符号整数比较的区别所在. 在<深入理解计算机系统>(英文版第二版)一书中的Page#77,有下面一个练习题: 将上述示例代码写入foo1.c文件, ...

  7. Eclipse: User Operation is waiting for “Building Workspace”

    这个情况可能有多个原因导致,比如,非正常关闭eclipse,时钟不匹配等等,可能解决的方法有: 1. 删除<workspace_folder>/.metadata/.lock文件 2. e ...

  8. 实现MySQL数据库的实时备份

    实现MySQL数据库的实时备份 使用MySQL Replication 吴剑 2018-08-03 原创文章,转载必需注明出处:http://www.cnblogs.com/wu-jian 吴剑 ht ...

  9. git hub 建立公钥

    1.  执行 $ eval "$(ssh-agent -s)" 2. 增加 ssh $ ssh-add ~/.ssh/id_rsa 3. 复制 生成的key (执行下面命令后就相当 ...

  10. Android6.0内核移植(1):分析编译日志

    在下面命令之后产生的编译日志进行分析 source build/envsetup.sh lunch sabresd_6dq-user make -j20 ======================= ...