您好,欢迎来到吉趣旅游网。
搜索
您的当前位置:首页软件测试实验报告2

软件测试实验报告2

来源:吉趣旅游网
- -

软件测试实验报告

题目名称: 计算下一天时间测试 专业班级: 软件三班 学 号: 041140338 姓 名:王超

. . word.zl

学生 实验工程 王超 学号 - -

041140338 同组人:无 等价类测试用例的生成 □必修 ■选修 □演示性实验 □验证性实验 ■操作性实验 □综合性实验 实验地点 指导教师 学校实验室 劲松教师 实验仪器台号 实验日期及节次 4号 3.4节

一、实验综述

1、实验目的及要求

实验目的:

掌握等价类测试方法的原理及使用。 实验要求:

〔1〕完成各个程序的编写

〔2〕按要求设计测试用例,并运行测试用例检查程序的正确与否 实验容:

对日期操作函数进展等价类测试方法的测试用例设计及测试结果记录与分析。

2、实验仪器、设备或软件

1. 个人计算机PC;

2. VisualC++/.NET编程环境。

二、实验过程〔实验步骤、记录、数据、分析〕

1.程序有三个变量〔月份、日期、和年〕的函数,函数返回输入日期后面的那个日期。变量都

具有整数值,且满足以下条件: C1 1<=月份<=12 C2 1<=日期<=31 确定等价类

M1={月份:每月有30天} M2={月份:每月有31天} M3={月份:此月是2月} D1={日期:1<=日期<=28} D2={日期:日期=29} D3={日期:日期=30}

. . word.zl

- -

D4={日期:日期=31} Y1={年:年是闰年} Y2={年:年是平年}

一般等价类测试用例应该有

3个〔月份类〕x 4个〔日期类〕x 2〔年类〕= 24个

测试用例 1 2 3 4 5 6 7 8 9 10 11 12 13 mouth 6 6 6 6 6 6 6 6 6 6 6 6 6 day 15 15 15 15 15 15 17 -1 1 2 30 31 32 year 1911 1912 1913 1975 2049 2050 2051 1912 1912 1912 1912 1912 1912 14 15 16 17 18 19 -1 1 2 11 12 13 15 15 15 15 15 15 1912 1912 1912 1912 1912 1912 . . word.zl

预期输出 1911.6.16 1912.6.16 1913.6.16 1975.6.16 2049.6.16 2050.6.16 2051.6.18 day超出[1…31] 1912.6.2 1912.6.3 1912.7.1 输入日期超界 day超出[1…31] 实际输出 1911.6.16 1912.6.16 1913.6.16 1975.6.16 2049.6.16 2050.6.16 2051.6.18 Error input 1912.6.2 1912.6.3 1912.7.1 Error input Error input Mouth超出[1…12] 1912.1.16 1912.2.16 1912.11.16 1912.12.16 Mouth超出[1…12] Error input 1912.1.16 1912.2.16 1912.11.16 1912.12.16 Error input - - 20 21 22 23 24 25 26 2 2 2 2 2 2 2 27 28 29 30 27 28 30 2000 2000 2000 2000 2001 2001 2001 2000.2.28 2000.2.29 2000.3.1 Day超出 2001.2.28 2001.3.1 Day超出 2000.2.28 2000.2.29 2000.3.1 Error input 2001.2.27 2001.2.28 Error input 通过分析前两个测试用例表,就会发现这些测试用例是不充分的,而且存在冗余。 测试用例: 1.对日期进展测试

1)输入-1日,年月正常输入。

2)输入1日,年月正常输入。

3)输入15日,年月正常输入。

4)输入30日,年月正常输入。

5)输入30日,年月正常输入。

. . word.zl

- -

6)输入31日,年月正常输入。

7)输入32日,年月正常输入。

2.对月份进展测试

1)输入-1月,年正常输入。

2)输入1月,年日正常输入。

3)输入6月,年日正常输入。

4)输入12月,年日正常输入。

. . word.zl

- -

5)输入13月,年正常输入。

3.闰年的2月进展检测

4.检测平年的2月份

3.检测结果:

经过检测发现程序既能判断闰年,也能判断平年情况下的下一天的日期。计算的日期很准确

三、结论

1、实验结果

〔1〕在给定正常年月日的情况下,能够判断下一天的日期。 〔2〕输入的年月日不在正常围,有提示,直到输入正确为止。

〔3〕既能判断平年,也能判断闰年的下一天日期。 2、分析讨论

本程序成功的实现了平年和闰年所输入日期的下一天的计算。

3、附加代码

. . word.zl

- -

import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Scanner; publicclass T {

publicstaticint[] dates = newint[3];

publicstaticvoid main(String[] args) throws Exception { String[] input = { \"input year :\", \"input month :\", \"input day :\" }; Scanner sc = new Scanner(System.in); for (int i = 0; i < input.length; i++) { dates[i] = input(input[i], sc, i); } Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, dates[0]); calendar.set(Calendar.MONTH, dates[1] - 1); calendar.set(Calendar.DATE, dates[2] + 1); SimpleDateFormat sdf = new SimpleDateFormat(\"yyyy-MM-dd\"); System.out.println(sdf.format(calendar.getTime())); } publicstaticint input(String message, Scanner sc, int index) { while (true) { System.out.print(message); String str = sc.nextLine(); try {

int result = Integer.parseInt(str);

if (index == 1 && !(result >= 1 && result <= 12)) { System.out.println(\"月份必须在1≤month≤12之间\"); continue; } if (index == 2) {

int end = endDay(dates[0], dates[1]); if (!(result >= 1 && result <= end)) { System.out.println(\"此年此月份的天数必须在1≤day≤\" + end+\"之间\");

continue; } } return result; } catch (Exception e) { System.out.println(\"input error!\"); } } }

publicstaticint endDay(int year, int month) { Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, month); c.set(Calendar.DATE, 0);

. . word.zl

- -

return c.get(Calendar.DATE); } }

四、指导教师评语及成绩:

评语:

. . word.zl

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- jqkq.cn 版权所有

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务