《软件测试》指导书(2)

2018-11-18 21:12

Output(“Enter today?s date in form MM DD YYYY”) Input(month,day,year) Case month of

Case 1: month Is 1,3,5,7,8, Or 10:?31 day months(except Dec.) If day<31

Then tomorrowDay = day+1 Else

TomorrowDay=1

TomorrowMonth=month+1

Endif

Case 2: month Is 4,6,9, or 11 ?30 day months If day<30

Then tomorrowDay=day+1 Else

TomorrowDay=1

TomorrowMonth=month+1

Endif

Case 3: month is 12:?December If day<31

Then tomorrowDay=day+1 Else

TomorrowDay=1 TomorrowMonth=1 If year=2012

Then Output(“2012 is over”)

Else tomorrow.year=year+!

Endif

Case 4:month is 2:?February If day<28

Then tomorrowDay=day+1 Else

If day=28 Then

If (year is a leap year)

Then tomorrowDay=29 ? leap year Else ?not a leap year TomorrowDay=1 TomorrowMonth=3 Endif Else if day=29

Then tomorrowDay=1 TomorrowMonth=3

Else output(“Cannot have Feb.”,day) Endif

2

Endif

Endif Endcase

Output(“Tomorrow?s date is”, tomorrowMonth, tomorrowDay, tomorrowYear) End Nextdate

(3)设计佣金问题的程序

Program commission (Input ,Output) Dim locks, stocks, barrels as Integer

Dim lockPrice, sotckPrice, barrelPrice as Real Dim totalLocks, totalStocks, totalBarrels as Integer Dim lockSales, stockSales, barrelSales as Rreal Dim sales, commission as Real

LockPrice=45.0 StockPrice=30.0 BarrelPrice=25.0 TotalLocks=0 TotalStocks=0 TotalBarrels=0

Input( locks)

While NOT(locks= -1) Input(stocks, barrels)

TotalLocks = totallocks + locks TotalStocks = totalStocks + stocks TotalBarrels = totalBarrels + barrels Input(locks) End while

Output(“locks sold:”, totalLocks) Output(“Stocks sold:”, totalStocks) Output(“Barrels sold:”, totalBarrels)

LockSales = lockPrice * totalLocks StockSales = StockPrice * totalStocks BarrelSales = barrelPrice * totalBarrels

Sales = lockSales + stockSales + barrelSales Output(“Total sales:”, sales)

If (sales > 1800.0) Then Commission = 0.1*1000.0

3

Commission = commission + 0.15 * 800.0 Commission = commission + 0.20*(sales – 1800.0) Else if (sales>1000.0) Then Commission = 0.10 * 1000.0 Commission = commission + 0.15 *(sales – 1000.0) Else commission = 0.10 * sales Endif Endif

Output(“Commission is $”, commission) End Commission

4

实验二 功能性测试(1学时)

一、实验目的

(1)掌握边界值、等价类和决策表测试的基本方法

二、实验要求

(1)完成各个程序的编写

(2)运用功能性测试方法设计被测程序的测试用例,并运行测试用例检查程序的正确与否

三、实验内容

(1)设计三角形问题的边界值测试用例

按照边界值测试的测试方法,对于三角形问题的边界值分析测试用例如下:

边界值分析测试用例

用例 a b c 预期输出 1 100 100 1 等腰三角形 2 100 100 2 等腰三角形 3 100 100 100 等边三角形 4 100 100 199 等腰三角形 5 100 100 200 非三角形 6 100 1 100 等腰三角形 7 100 2 100 等腰三角形 8 100 100 100 等边三角形 9 100 199 100 等腰三角形

10 100 200 100 非三角形

11 1 100 100 等腰三角形 12 2 100 100 等腰三角形 13 100 100 100 等边三角形 14 199 100 100 等腰三角形 15 200 100 100 非三角形

(2)对于nextdate函数设计决策表测试用例程序

我们选择如下的等价类:

M1={月份:每月有30天} M2={月份:每月有31天,12月除外} M3={月份:此月是12月} M4={月份:此月是2月} D1={日期:1≤日期≤27} D2={日期:日期=28} D3={日期:日期=29} D4={日期:日期=30}

D5={日期:日期=30} Y1={年:年是闰年} Y2={年:年不是闰年}

5

1 2 3 4 5 6 7 8 9 10 C1:月份在 M1 M1 M1 M1 M1 M2 M2 M2 M2 M2 C2:日期在 C3:年在 A1:不可能 A2:日期增1 A3:日期复位 A4:月份增1 A5:月份复位 A6:年增1 D1 — × D2 — × D3 — × D4 — × × D5 — × D1 — × D2 — × D3 — × D4 — × D5 — × × 11 12 13 14 15 16 17 18 19 20 21 22 C1:月份在 M3 M3 M3 M3 M3 M4 M4 M4 M4 M4 M4 M4 C2:日期在 C3:年在 A1:不可能 A2:日期增1 A3:日期复位 A4:月份增1 A5:月份复位 A6:年增1 D1 — × D2 × D3 × D4 × D5 — × × × D1 — × D2 Y1 × D2 Y2 × × D3 Y1 × × D3 Y2 × D4 — × D5 — × (3)对于佣金问题设计出等价类测试用例 我们选择如下等价类:

L1={枪机:1≤枪机≤70} L2={枪机=-1}

S1={枪托:1≤枪托≤80} B1={枪管:1≤枪管≤90}

输入变量对应的无效类是:

6


《软件测试》指导书(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:国家ICD编码

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: