软件测试基础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的安装
白盒测试:需要了解内部结构和代码 黑盒测试:不关心内部结构和代码 灰盒测试:介于白盒黑盒之间 静态测试:测试时不执行被测试软件 动态测试:测试时执行被测试软件 单元测试:测试软件的单元模块 集成测试: ...
随机推荐
- vim编辑技巧
算上大学上课linux接触四年了,可惜除了工作接触的那些,其他地方还是很水的,都不精通,今日翻来看了看以前过目即忘的vim技巧,发现,如无几年操作经验,这些技巧很难领悟的.这里写下来,以备后查. 区块 ...
- SQL Server 2008 R2 企业版/开发版/标准版(中英文下载,带序列号)
一. 简体中文 1. SQL Server 2008 R2 Developer (x86, x64, ia64) – DVD (Chinese-Simplified) File Name: cn_sq ...
- Android笔记:异步消息处理
1. Message Message 是在线程之间传递的消息,它可以在内部携带少量的信息,用于在不同线程之间交换数据.上一小节中我们使用到了Message 的what 字段,除此之外还可以使用arg1 ...
- c#中取整,向上取,向下取
Math.Ceiling()向上取整, Math.Floor()向下取整 示例: d = 4.56789 Math.Ceiling(Convert.ToDecimal(d)).ToString();M ...
- 统一配置管理-百度disconf
之前一直采用properties文件管理配置信息,若是集群则每个机器上都要拷贝一份,每次修改也需要依次修改.一直在寻找统一修改,实时生效,方便修改,分环境分系统的配置管理,自己也在整理设计,若找不到合 ...
- thinkphp 3.23语言包加载
模块home: 1.config 里添加 配置 //'配置项'=>'配置值' 'LANG_SWITCH_ON' => true, // 开启语言包功能 'LANG ...
- ca 自签名证书 并实现HAProxy https功能
mkdir /etc/ssl/xip.io [root@ha02 haproxy-]# openssl genrsa - Generating RSA bit long modulus ....... ...
- PCM数据格式,多少字节算一帧
转自:http://blog.chinaunix.net/uid-9185047-id-3327302.html Somehow i remember that normally 2048 sampl ...
- Winform实现用多线程、百度地图API解析某公司的物理地址
前言 作为一个很挫的C#新手总喜欢自己写点儿不着边际的东西,本人是个新手加菜鸟,写B/S的,工作中,任务完成了,空闲下来,总想继续学点儿什么,由此触发了本篇文章了.个人一直认为,.NET中,C/S所要 ...
- Hadoop Linux安装
Hadoop Linux安装 步骤流程 1.硬件准备 2.软件准备(推荐CDH) 3.将Hadoop安装包分发到各个节点下 4.安装JDK 5.修改/etc/hosts配置文件 6.设置SSH免密码登 ...