the third assignment of software testing
没有网的日子不好过,Junit4下不下来,先用androidTestCase实现一个。
遇到了几个bug。
首先是除0问题。
public void testDivide(){
result=calculate.divide(5, 2);
if(calculate.getIsError()){
assertEquals(flag, true);
}else{
assertEquals(2.5, result);
}
double result1=calculate.divide(5, 0);
if((flag=calculate.getIsError())){
assertEquals(flag, true);
}else{
assertEquals(2.5, result1);
}
double result2=calculate.divide(0, 5);
if(calculate.getIsError()){
assertEquals(flag, true);
}else{
assertEquals(0, result2);
}
}
我这里是这样解决的。看某一个ifelse即可。
对于计算器来说,他应该是知道除法能不能被零,以及除完的后果的,所以我为Calculate多设置了一个变量 isError,是否出错。如果被零除,认为出错,进行setIsError操作。即先判定是否出错。是,则断言结果assertEquals(flag, true);成立。否则assertEquals(2.5, result1);得到对应结果。
Bug2

图一:一个好长的错误。
这个当时看了好几遍,都没觉得有啥问题,害的我把数值全都变成整形,后来发现没问题,但总觉得不舒服,于是 看到了这里,然后两个数值相减小于一个很小的数,就认为他们相等,于是:
public void testMinus(){
double result2=calculate.minus(5,8.3);
double expected=-3.3;
if((expected-result2)<0.0000001){
setIsEqual();
}
assertEquals(true, isEqual);
}
在乘法操作发现了这些:

图二:16跟16.0可不相等。
于是:
public void testMultiple(){
result=calculate.multiple(5, 3.2);
assertEquals(16.0, result);
}
然后问题就基本解决完了。
一个简单的加减乘除的测试就完成了。
之后找到了,junit4这个jar包,通过配置只要把下载好的类库导入到文件中就可以了。(依然可以通过留邮箱的方式来获得这些开源文件,如果你找不到,或者不太愿意花点时间找的话。)
这里就给出比较简单的加减乘除的实现方式:
所有测试数据都是最简单的。没有做任何防护措施。
https://github.com/bzdwdmzjsmff
可以到这个地址下寻找相应源代码。
the third assignment of software testing的更多相关文章
- the first assignment of software testing
Github ID: bzdwdmzjsmff Github address: https://github.com/bzdwdmzjsmff alternative article: Increa ...
- the forth assignment of software testing
软件测试用到的 pict33.msi. 加载安装即可. 顺步安装 使用背景: 假如现在有一个网站后台需要测试工程师进行测试用例设计.用常规的方法将参数列出: 帐户名: 空,不存在,超长,超短,正常 密 ...
- the second assignment of software testing
作业2期心得体会.第一期仍有未完成的项目,比如应该指定所读课题的范围,是关于哪个方面的. 作业项目一: 安装并使用CheckStyle/PMD与FindBug 现在网络上查找了一番发现checkSty ...
- 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 ...
- Software Testing Techniques LAB 02: Selenium
1. Installing 1. Install firefox 38.5.1 2. Install SeleniumIDE After installing, I set the view o ...
随机推荐
- centos6.5安装vbox
cd /etc/yum.repos.d wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo 下载跟CENTO ...
- BZOJ3585: mex
3585: mex Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 322 Solved: 169[Submit][Status] Descripti ...
- openssl的CRYPTO_set_locking_callback
openssl可以在多线程环境下使用,但前提是向openssl提供线程锁设施,通过CRYPTO_set_locking_callback设置. 在一些复杂软件环境环境中,可能存在多个上层模块同时使用o ...
- apache开源项目--kylin
Kylin 是一个开源的分布式的 OLAP 分析引擎,来自 eBay 公司开发,基于 Hadoop 提供 SQL 接口和 OLAP 接口,支持 TB 到 PB 级别的数据量. Kylin 是: 超级快 ...
- HDU4725 The Shortest Path in Nya Graph dij
分析:对于每一层,原来n个点,然后扩展为原来的三倍,每一层扩展一个入点,一个出点,然后跑最短路 注:tmd我把一个n写成m了,然后wa了7次,我都要怀疑人生了 #include<cstdio&g ...
- 并查集 poj1611&poj2492
poj1611 简单题 代码中id记录父节点,sz记录子树规模.一个集合为一棵树. #include <iostream> #include <cstdio> using na ...
- 10670 Work Reduction (贪心 + 被题意坑了- -)y
Problem C: Work Reduction Paperwork is beginning to pile up on your desk, and tensions at the workpl ...
- oc学习之路----scrollView的代理模式
右图是OC里面scrollView的代理的描述,从这里可以开出来,任何对象都可以作为scorllView的代理对象只要实现了UIScrollViewDelegate这个协议,为什么呢,原因要追究到UI ...
- 三角形div的原理
三角形div原理 首先我们写一个正常的方形div样式,但是我们把它的宽度和高度都设置为零,并且边框线设置的粗一点: { width:0px: height:0px; Border:20px solid ...
- Spring Batch Framework– introduction chapter(下)
Extract,Transform, and load(ETL) Briefly stated, ETL is a process in the database anddata-warehousin ...