软件测试Lab 1 Junit and Eclemma
首先安装eclipse
然后下载hamcrest-core-1.3.jar,下载地址:http://mvnrepository.com/artifact/org.hamcrest/hamcrest-core/1.3
下载junit-4.12.jar,下载地址:http://mvnrepository.com/artifact/junit/junit/4.12
然后安装Eclemma,打开eclipse,点击Help->Eclipse Market Place
安装重启eclipse即可,若出现图标即表示安装成功。
创建一个project,格式如下
package Triangle; public class Triangle {
public int isTriangle(int a,int b,int c){
if(a>0 && b>0 && c>0 && a+b>c && a+c>b && b+c>a){
return 1;
}
return 0;
}
public int equilateral(int a,int b,int c){
if(isTriangle(a,b,c)==1){
if(a==b && b==c){
return 1;//等边
}
}
return 0;
}
public int isosceles(int a,int b,int c){
if(isTriangle(a,b,c)==1){
if(a==b || b==c || a==b){
return 1;//等腰
}
}
return 0;
}
public int scalene(int a,int b,int c){
if(isTriangle(a,b,c)==1){
if(a==b || b==c || a==b){
return 0;//等腰
}
return 1;
}
return 0;
}
}
package Triangle;
import static org.junit.Assert.*;
import org.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith; public class TestTri {
Triangle tri=new Triangle(); @Test
public void testisTriangle(){
assertEquals(1,tri.isTriangle(1,1,1));
}
@Test
public void testequilateral(){
assertEquals(1,tri.equilateral(1,1,1));
}
@Test
public void testisosceles(){
assertEquals(1,tri.isosceles(1,1,1));
}
@Test
public void testscalene(){
assertEquals(1,tri.scalene(1,1,1));
}
}
测试结果:
软件测试Lab 1 Junit and Eclemma的更多相关文章
- 软件测试:lab1.Junit and Eclemma
软件测试:lab1.Junit and Eclemma Task: Install Junit(4.12), Hamcrest(1.3) with Eclipse Install Eclemma wi ...
- 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- ...
- 单元测试系列:如何使用JUnit+JaCoCo+EclEmma完成单元测试
更多原创测试技术文章同步更新到微信公众号 :三国测,敬请扫码关注个人的微信号,感谢! 原文链接:http://www.cnblogs.com/zishi/p/6726664.html -----如 ...
- 软件测试第一次试验JUnit
一.Junit, hamcrest以及eclemma的安装 对于Junit和hamcrest的安装,我并没有从下载Junit和hamcrest相关的jar包然后通过build path导入到项目中,而 ...
- 使用junit和eclemma进行简单的代码测试
1.Junit和Hamcrest的安装 可以在https://mvnrepository.com/上面下载所需要的Junit和Hamcrest的jar包,然后在项目中新建一个lib文件夹,将下载好的j ...
- 软件测试入门 1—— junit 单元测试
一.实验主要内容: 1. 2.EclEmma安装 见: http://www.cnblogs.com/1995hxt/p/5291465.html 二.对与 Junit 安装,使用 maven管理项目 ...
- 软件测试作业3 — PrintPrimes()
一.Use the following method printPrimes() for questions a–d. (a) Draw the control flow graph for the p ...
- 软件测试-homework3
printPrime()代码: public static void printPrimes (int n) { int curPrime; // Value currently considered ...
- 软件测试技术作业3---PrintPrimes()
一.代码部分: private static void printPrimes (int n) { int curPrime; // Value currently considered for pr ...
随机推荐
- hdu1074
#include <iostream> #include <string> #include <cstring> #include <stack> #i ...
- 图像的读取,显示与保存(基于skimage模块)
一 skiamge模块 skimage包的全称是scikit-image SciKit (toolkit for SciPy) ,它对scipy.ndimage进行了扩展,提供了更多的图片处理功能.它 ...
- HTML5 为 <input> 增加的属性 ; 为 <form> 增加的如需属性
HTML5 为 <input> 增加了如下属性: autocomplete autofocus form formaction formenctype formmethod formnov ...
- Hadoop中解除 "Name node is in safe mode"的方法
运行hadoop程序时,有时候会报以下错误,说明Hadoop的NameNode处在安全模式下. 原因分析: 在分布式文件系统启动的时候,开始的时候会有安全模式,当分布式文件系统处于安全模式的情况下,文 ...
- PHP-CGI远程任意代码执行漏洞(CVE-2012-1823)修复方案
首先介绍一下这个漏洞,其实是在apache调用php解释器解释.php文件时,会将url参数传我给php解释器,如果在url后加传命令行开关(例如-s.-d .-c或 -dauto_prepend_ ...
- Scrapy框架中的Pipeline组件
简介 在下图中可以看到items.py与pipeline.py,其中items是用来定义抓取内容的实体:pipeline则是用来处理抓取的item的管道 Item管道的主要责任是负责处理有蜘蛛从网页中 ...
- BZOJ 3796 Mushroom追妹纸 哈希+二分(+KMP)
先把两个串能匹配模式串的位置找出来,然后标记为$1$(标记在开头或末尾都行),然后对标记数组求一个前缀和,这样可以快速查到区间内是否有完整的一个模式串. 然后二分子串(答案)的长度,每次把长度为$md ...
- Angular2.0的学习(四)
第四节课:数据绑定.响应式编程和管道 1.数据绑定(插值表达式.事件绑定.属性绑定.双向绑定) 2.响应式编程 3.管道
- DateAdapter
import java.text.SimpleDateFormat;import java.util.Date; import javax.xml.bind.annotation.adapters.X ...
- JavaScript 获取 Url 上的参数(QueryString)值
获取URL里面传的参数,在Js中不能像后台一样使用Request.QueryString来获取URL里面参数,下面介绍两种方式用来获取参数 方式一:使用split分隔来获取,这种方法考试了地址中包含了 ...