Software Testing, Lab 1
1、Install Junit(4.12), Hamcrest(1.3) with Eclipse
2、Install Eclemma with Eclipse
3、Write a java program for the triangle problem and test the program with Junit.
Description of triangle problem:
Function triangle takes three integers a,b,c which are length of triangle sides; calculates whether the triangle is equilateral, isosceles, or scalene.
Triangle.java:
package cn.st.lab1; public class Triangle {
public static boolean isTriangle(int a, int b, int c) {
if(a+b>c && a+c>b && b+c>a && Math.abs(a-b)<c &&
Math.abs(a-c)<b && Math.abs(b-c)<a && a>0 && b>0 && c>0) {
return true;
}
else {
return false;
}
}
public static boolean isEquilateral(int a, int b, int c) {
if(isTriangle(a,b,c)) {
if(a == b && a == c) {
return true;
}
}
return false;
}
public static boolean isIsosceles(int a, int b, int c) {
if(isTriangle(a,b,c)) {
if(a == b || a == c || b == c) {
return true;
}
}
return false;
} public static void Triangle (int a, int b, int c) {
if(isTriangle(a,b,c)) { //输出以下内容,则为三角形
if(isEquilateral(a,b,c)) {
System.out.println("Equilateral");
} //如果是等边,只输出等边,不输出等腰
else if(isIsosceles(a,b,c)) {
System.out.println("Isosceles");
}
else {
System.out.println("Scalene");
}
}
else {
System.out.println("NotATriangle");
}
}
testTriangle.java:
package cn.st.lab1; import static org.junit.Assert.*; import org.junit.*; public class testTriangle { Triangle t;
@Before
public void setUp(){
t = new Triangle();
} @Test
public void testIsEquilateral() {
assertEquals("testIsEquilateral", true, t.isEquilateral(6,6,6));
}
@Test
public void testIsIsosceles() {
assertEquals("testIsIsosceles", true, t.isIsosceles(5,6,6));
}
@Test
public void testIsTriangle() {
assertEquals("testIsTriangle", true, t.isTriangle(5,6,7));
}
@Test
public void testTriangle() {
t.Triangle(3, 4, 5);
t.Triangle(3, 4, 4);
t.Triangle(4, 4, 4);
t.Triangle(1, 1, 5);
}
}
实验结果:
代码请见github:https://github.com/fogmisty/SoftwareTest
Software Testing, Lab 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 ...
- 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 [美] 詹姆斯·惠特克(软件测 ...
- 软件测试software testing summarize
软件测试(英语:software testing),描述一种用来促进鉴定软件的正确性.完整性.安全性和质量的过程.软件测试的经典定义是:在规定的条件下对程序进行操作,以发现程序错误,衡量软件质量,并对 ...
- 读书笔记-Software Testing(By Ron Patton)
Software Testing Part I:The Big Picture 1.Software Testing Background Bug's formal definition 1.The ...
- software testing
Software Testing Software testing is the process of evaluation a software item to detect differences ...
- 探索式软件测试—Exploratory Software Testing
最近找到去年上半年看过一本关于测试方面书籍的总结笔记,一直放在我的个人U盘里,当时是用Xmind记录的,现在重新整理下分享给大家了! James A.Whittaker [美] 詹姆斯·惠特克(软件测 ...
- FW:Software Testing
Software Testing Testing with a Purpose Software testing is performed to verify that the completed s ...
- 《The art of software testing》的一个例子
这几天一直在看一本书,<The art of software testing>,里面有一个例子挺有感触地,写出来和大家分享一下: [问题] 从输入对话框中读取三个整数值,这三个整数值代表 ...
随机推荐
- 通过动态SQL语句创建游标
DECLARE @sql varchar(100); DECLARE @TableName varchar(32); DECLARE @FieldName varchar(32); DECLARE @ ...
- JS保留两位小数的几种方法
四舍五入 以下处理结果会四舍五入: var num =2.446242342; num = num.toFixed(2); // 输出结果为 2.45 不四舍五入 以下处理结果不会四舍五入: 第一种, ...
- 利用TortoiseGit(小乌龟)将项目上传至GitHub网站
准备 1.拥有一个GitHub账户 2.安装了TortoiseGit(小乌龟) 具体过程 一.在GitHub上建立新的仓库 起好仓库名,填好描述,在Add .gitgnore中选择Java(根据你自己 ...
- 同步调用异步方法how-would-i-run-an-async-taskt-method-synchronously
同步调用异步方法帮助类: public static class AsyncHelpers { /// <summary> /// Execute's an async Task<T ...
- laravel5.8笔记五:基类控制器和基类模型
建立基类的目的就是为了方便继承.比如:Admin模块访问,是否登陆.检测登陆可以写到基类里面 控制器基类 原始基类:app\Http\Controllers\Controller.php,我们下面要做 ...
- 手写一个selenium浏览器池
维护一组浏览器,实现每分钟1000次查询.DriverPool使用变幻版只初始化一次的单例模式.维护每个浏览器的当前是否使用的状态. 不需要等待请求来了,临时开浏览器,开一个浏览器会耽误6秒钟. 可以 ...
- elasticsearch 6.1.1 transport jar
https://files.cnblogs.com/files/xjyggd/transport6.1.1.rar
- 11.8Django中的组件content_type
2018-11-8 18:59:11 在Django中已经有一个contenttype这个组件,并且在python manage.py makemigrations 和migrate的时候,一起在数据 ...
- linux 的基本操作(linux系统的日常管理)
系统的日常管理 笔者在前面介绍的内容都为linux系统基础类的,如果你现在把前面的内容全部很好的掌握了,那最好了.不过笔者要说的是,即使你完全掌握了,你现在还是不能作为一名合格的linux系统管理员的 ...
- 为 git设置代理
普通设置 git config --global http.proxy 'socks5://127.0.0.1:1080'git config --global https.proxy 'socks5 ...