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. 完美原创:centos7.1 从源码升级安装Python3.5.2

    (原创)完美原创:centos7.1 从源码升级安装Python3.5.2 下载Python3.5.2源码:https://www.python.org/downloads/release/pytho ...

  2. Git的介绍和使用

    Git是目前世界上最先进的分布式版本控制系统 Git的安装 1.在linux上安装 你可以先输入git,看看系统是不是已经自带了git 或者 sudo apt-get install git  就可以 ...

  3. smarty 教程 及 常用点

    1. 简单例子 有助回忆基本知识点 define("DIR",dirname(__FILE__)); require_once(DIR."/libs/Smarty.cla ...

  4. javac之向前引用

    可以参考JLS7:https://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.3.2.3 public class Test5 ...

  5. windows10安装tensorflow CPU版本

    1.先安装python3.6版本 a.安装完成后在cmd中输入python,如果出现python命令行模式,则说明python安装成功. 2.在cmd中输入pip3 install --upgrade ...

  6. Nginx教程(6) 负载均衡

    一原理 二例子 在 nginx-1.13.0.tar.gz下测试 upstream test { server 192.168.56.90:8180 weight=1 max_fails=3 fail ...

  7. 前端自动化Gulp工具常用插件

    npm init命令初始化当前文件夹后,在当前文件夹新建gulpfile.js文件.当前目录下的所有操作流都在gulpfile.js文件中定义. gulp自动化 gulp-uglify (JS压缩) ...

  8. Elasticsearch使用BulkProcessor批量插入

    https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-document-bulk. ...

  9. Scrum 冲刺博客第三篇

    一.当天站立式会议照片一张 二.每个人的工作 (有work item 的ID),并将其记录在码云项目管理中 昨天已完成的工作 基本的页面设计 各个页面之间的跳转 背景音乐模块设计 今天计划完成的工作 ...

  10. JAVA泛型——协变

    在上篇<JAVA泛型——基本使用>这篇文章中遗留以下问题,即将子类型Table或者也能添加到父类型Auction的泛型中,要实现这种功能必须借助于协变. 实验准备 现在在<JAVA泛 ...