软件测试基础homework3
//本次的作业为
/*******************************************************
* Finds and prints n prime integers
* Jeff Offutt, Spring 2003
******************************************************/
public static void printPrimes (int n)
{
int curPrime; // Value currently considered for primeness
int numPrimes; // Number of primes found so far.
boolean isPrime; // Is curPrime prime?
int [] primes = new int [MAXPRIMES]; // The list of prime numbers. // Initialize 2 into the list of primes.
primes [0] = 2;
numPrimes = 1;
curPrime = 2;
while (numPrimes < n)
{
curPrime++; // next number to consider ...
isPrime = true;
for (int i = 0; i <= numPrimes-1; i++)
{ // for each previous prime.
if (curPrime%primes[i]==0)
{ // Found a divisor, curPrime is not prime.
isPrime = false;
break; // out of loop through primes.
}
}
if (isPrime)
{ // save it!
primes[numPrimes] = curPrime;
numPrimes++;
}
} // End while // Print all the primes out.
for (int i = 0; i <= numPrimes-1; i++)
{
System.out.println ("Prime: " + primes[i]);
}
} // end printPrimes
一、画出控制流图

二、设计一个t2=(n=5)比t1=(n=3)容易发现发现的错误
数组越界的错误。
三、写一个测试用例,使相应的测试路径访问连接while语句开始到fot语句得边,而不用通过while的循环体
t:n=1
四、例举每个节点覆盖,边覆盖和主路径覆盖的TR
节点覆盖需求:{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}
边覆盖需求:{(1,2),(2,3),(3,5),(5,6),(6,7),(7,8),(7,9),(9,6),(8,10),(6,10),(10,11),(10,12),(11,2),(12,2),(2,4),(4,13),(13,14),(14,15),(14,16)}
主路径覆盖需求:
{(1,2,3,4,5,6,7),
(1,2,3,4,5,6,8,9,10,11),
(1,2,3,4,5,6,8,9,11),
(1,2,3,4,5,9,10,11),
(1,2,3,4,5,9,11),
(1,2,12,13,14,15),
(1,2,12,16),
(3,4,5,6,8,9,10,11,2,12,13,14,15),
(3,4,5,6,8,9,11,2,12,13,14,15),
(3,4,5,6,8,9,10,11,2,12,13,16),
(3,4,5,6,8,9,11,2,12,13,16),
(3,4,5,9,10,11,2,12,13,14,15),
(3,4,5,9,11,2,12,13,14,15),
(3,4,5,9,10,11,2,12,13,16),
(3,4,5,9,11,2,12,13,16),
(6,7,5,9,10,11,2,12,13,14,15),
(6,7,5,9,11,2,12,13,14,15),
(6,7,5,9,10,11,2,12,13,16),
(6,7,5,9,11,2,12,13,16),
(14,15,13,16),
(13,14,15,13),
(5,6,7,5),
(2,3,4,5,6,8,9,10,11,2),
(2,3,4,5,6,8,9,11,2),
(2,3,4,5,9,10,11,2),
(2,3,4,5,9,11,2),
}
五、实现一个主路径覆盖的测试
package example; /**
* Created by Ev_Eraser on 2016/3/18.
*/
public class Myclass {
public String triangle(int a,int b,int c) {
if(a + b < c || a + c < b || b+ c < a)
return "notTriangle";
if(a == b && b == c)
return "isosceles";
if(a == b || b == c || a == c)
return "equilateral";
else
return "scalene";
}
}
测试类用例:
package example; import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import static org.junit.Assert.*;
@RunWith(Parameterized.class)
public class MyclassTest {
private Myclass myClass;
private int input1;
private int input2;
private int input3;
private String expected; public MyclassTest(int input1, int input2,int input3,String expected){
this.input1 = input1;
this.input2 = input2;
this.input3 = input3;
this.expected = expected; }
@Before
public void setUp() throws Exception {
myClass = new Myclass();
} @Parameterized.Parameters
public static Collection<Object[]> getData(){
return Arrays.asList(new Object[][]{
{2,2,2,"isosceles"},
{2,2,3,"equilateral"},
{2,4,3,"scalene"},
{2,9,2,"notTriangle"}
});
} // @After
// public void tearDown() throws Exception {
//
// } @Test
public void testTriangle() throws Exception {
assertEquals(this.expected, myClass.triangle(input1,input2,input3));
}
}

软件测试基础homework3的更多相关文章
- web软件测试基础系统测试简化理论
系统测试点主要如下 1.系统测试基础-2.测试对象与测试级别-3.系统测试类型-4.系统测试方法-5.系统测试之软件测试质量. 1.系统测试:是尽可能彻底地检查出程序中的错误,提高软件系统的可靠性. ...
- 软件测试基础Ⅲ(osi7层协议,测试模型,LoadRunner组件,软件质量模型)
osi7层开放式系统互连网络模型 1.物理层:主要定义物理设备标准,如网线的接口类型.光纤的接口类型.各种传输介质的传输速率等.它的主要作用是传输比特流(就是由1.0转化为电流强弱来进行传输,到达目的 ...
- part1 软件测试基础知识面试题(含答案)
1.你的测试职业发展是什么? 测试经验越多,测试能力越高.所以我的职业发展是需要时间积累的,一步步向着高级测试工程师奔去.而且我也有初步的职业规划,前3年积累测试经验,按如何做好测试工程师的要点去要求 ...
- [软件测试基础2]基于selenium的自动化测试
这次上机我们主要使用Selenium进行自动化测试,首先我们需要下载selenium-java的依赖项. 若使用maven管理项目,则在.pom文件中加入如下依赖项: <dependency&g ...
- [软件测试基础3]基于Jemter的压力测试
一.整体目标 安装LAMP待测系统,推荐ECShop,基于此进行Jmeter压力测试,并在测试后得出Jmeter测试报告,并根据sysstat得出Linux服务器的CIMN(CPU,IO,Memory ...
- 软件测试基础homework2
1.for循环里的i>0应该改为i>=0 test1:x=[3,2,5];y=2 test2:x=[3];y=2 test3:x=[2,3,5];y=4 2.for循环里的i应该倒序 te ...
- 软件测试基础(软件测试分类和工具组)firebug、firepath的安装
白盒测试:需要了解内部结构和代码 黑盒测试:不关心内部结构和代码 灰盒测试:介于白盒黑盒之间 静态测试:测试时不执行被测试软件 动态测试:测试时执行被测试软件 单元测试:测试软件的单元模块 集成测试: ...
- 软件测试基础-Homework1
The error was in my graduate work which was about game development.I broadcast some messages to the ...
- 【Selenium】软件测试基础(软件测试分类和工具组)firebug、firepath的安装
白盒测试:需要了解内部结构和代码 黑盒测试:不关心内部结构和代码 灰盒测试:介于白盒黑盒之间 静态测试:测试时不执行被测试软件 动态测试:测试时执行被测试软件 单元测试:测试软件的单元模块 集成测试: ...
随机推荐
- NSLOOKUP命令使用
nslooup命令,可以用来检测dns服务器是否可用,以及域名对应的真实ip,在一些网络dns不稳定的情况下可以使用,用来正确访问网站. Microsoft Windows [版本 6.1.7601] ...
- android 第三方登录 --- QQ
1,jar包 2,配置AndroidManifest.xml <activity android:name=".login.LoginActivity" android:co ...
- 局部加权回归、欠拟合、过拟合(Locally Weighted Linear Regression、Underfitting、Overfitting)
欠拟合.过拟合 如下图中三个拟合模型.第一个是一个线性模型,对训练数据拟合不够好,损失函数取值较大.如图中第二个模型,如果我们在线性模型上加一个新特征项,拟合结果就会好一些.图中第三个是一个包含5阶多 ...
- Java如何保存含有时间的日期到Oracle数据库
原文:http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#08_01 从Oracle ...
- PHP获取当前url路径的函数及服务器变量:QUERY_STRING、REQUEST_URI、SCRIPT...
1,$_SERVER["QUERY_STRING"]说明:查询(query)的字符串 2,$_SERVER["REQUEST_URI"]说明:访问此页面所需的U ...
- vs2008所有DTE.ExecuteCommand命令
下面列表中为我当前机器上visual studio 2008所有DTE.ExecuteCommand命令的内容: 其中:Build.开头对应“编译”菜单下命令(如:Build.RebuildSolut ...
- 国内其他的maven库
转自:http://www.cnblogs.com/woshimrf/p/5860478.html 在oschina关来关去的烦恼下,终于受不了去寻找其他公共库了. 阿里云maven镜像 <mi ...
- three.js自定义形状
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...
- js 字符串中的\n不会换行
var str1=aaaaaaa\nbbbbbbb; alert(str1); //不换行 ???不知所以然 解决办法: while (str1.indexOf("\\n") & ...
- pip安装模块
需要到pip目录下执行 pip install 模块名 pip 也需要配置环境变量,电脑是windows