Software Testing Techniques LAB 01: test Junit and Eclemma
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
- 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的更多相关文章
- Software Testing Techniques LAB 02: Selenium
1. Installing 1. Install firefox 38.5.1 2. Install SeleniumIDE After installing, I set the view o ...
- 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 ...
- 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 ...
- 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 ...
- 读书笔记-Software Testing(By Ron Patton)
Software Testing Part I:The Big Picture 1.Software Testing Background Bug's formal definition 1.The ...
- Web Application Penetration Testing Local File Inclusion (LFI) Testing Techniques
Web Application Penetration Testing Local File Inclusion (LFI) Testing Techniques Jan 04, 2017, Vers ...
- 101+ Manual and Automation Software Testing Interview Questions and Answers
101+ Manual and Automation Software Testing Interview Questions and Answers http://www.softwaretesti ...
- Exploratory Software Testing
最近找到去年上半年看过一本关于测试方面书籍的总结笔记,一直放在我的个人U盘里,当时是用Xmind记录的,现在重新整理下分享给大家了! James A.Whittaker [美] 詹姆斯·惠特克(软件测 ...
- 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 ...
随机推荐
- 【HADR】搭建实战
Summary: 简单的HADR,只用一台虚拟机,两个实例间搭建.工作量不大,一般5分钟左右能够完成. 步骤: 1.设定归档模式 2.使用备份建立standby数据库 3.设定hadr相关的参数 4. ...
- (转)MySQL自带的性能压力测试工具mysqlslap详解
mysqlslap 是 Mysql 自带的压力测试工具,可以模拟出大量客户端同时操作数据库的情况,通过结果信息来了解数据库的性能状况 mysqlslap 的一个主要工作场景就是对数据库服务器做基准测试 ...
- JavaScript定时器与执行机制
JavaScript动画中是必须使用到定时器的,这里做一个总结. var label = 'someLable'; console.time(label); console.timeEnd(label ...
- EasyMock set方法报错: java.lang.AssertionError
有返回值的方法没问题, 直接andReturn就行了. EasyMock.expect(info.getWebTitle()).andReturn(StringUtils.EMPTY).anyTime ...
- C 扩展库 - sqlite3 API
sqlite3 API Summary sqlite3 The database connection object. Created by sqlite3_open() and destroyed ...
- idp sp sso---SAML Single Sign-On (SSO) Service for Google Apps
src: https://developers.google.com/google-apps/sso/saml_reference_implementation Security Assertion ...
- Java泛型的协变
在上篇<Java泛型的基本使用>这篇文章中遗留以下问题,即将子类型也能添加到父类型的泛型中,要实现这种功能必须借助于协变. 实验准备 现在在上篇文章展示的Decorator类型的基础上,增 ...
- 基于 Annotation 的 Spring AOP 权限验证方法的实现
1. 配置 applicationContext 在 Spring 中支持 AOP 的配置非常的简单,只需要在 Spring 配置文件 applicationContext.xml 中添加: < ...
- C# 多维数组
int[, ,] shuzu = new int[4, 3, 2]; //有四个二维数组,每个二维数组里面有3个1维数组,每个1维数组里面有2个元素
- nodejs简易代理服务器
直接代码: var http = require('http') var proxy = http.createServer(function (request, response) { var op ...