软件测试nextdata程序,Nextdata测试用例及源程序.doc

1.测试程序源代码

public class Nextdata {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

int year;

int month;

int day;

java.util.Scanner input=new java.util.Scanner(System.in);

System.out.println("请输入年份:");

year=input.nextInt();

while(!(year>=1000&& year<=9999))

{

System.out.println("输入的年份不正确!");

return;

}

System.out.println("请输入月份:");

month=input.nextInt();

while (month>12||month<1)

{

System.out.println("月份输入有误,请重新输入!");

return;

}

System.out.println("请输入日期号:");

day=input.nextInt();

if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)

{

while (day>31||day<1)

{

System.out.println("日期输入有误,请重新输入!");

return;

}

}

if(month==4||month==6||month==9||month==11)

{

while (day>30||day<1)

{

System.out.println("日期输入有误,请重新输入!");

return;

}

}

if((year%4==0 && year%100!=0) || (year%400==0)) //检查闰年;

{

if(month==2)

{

if(day>29)

{

System.out.println("本月是闰月,请在1-29之间从新输入日期!");

return;

}

else

{

if(day==29)

{

day=1;

}

else day++;

}

}

}

else

{

if(month==2)

{

if(day>28)

{

System.out.println("本月是闰月,请在1-28之间从新输入日期!");

return;

}

else

{

if(day==28)

{

day=1;

}

else day++;

}

}

}

switch(month)

{

case 1:

case 3:

case 5:

case 7:

case 8:

case 10:

if (day==31)

{

month++;

day=1;

System.out.println("明天是:"+year+"-"+month+"-"+day);

break;

}

else{

day++;

System.out.println("明天是:"+year+"-"+month+"-"+day);

break;

}

case 2:

if(day==1)

{

month++;

System.out.println("明天是:"+year+"-"+month+"-"+day);

break;

}

else{

System.out.println("明天是:"+year+"-"+month+"-"+day);

break;

}

case 4:

case 6:

case 9:

case 11:

if(day==30)

{

month++;

day=1;

System.out.println("明天是:"+year+"-"+month+"-"+day);

break;

}

else{

day++;

System.out.println("明天是:"+year+"-"+month+"-"+day);

break;

}

case 12:

if(day==31)

{

year++;

month=1;

day=1;

System.out.println("明天是:"+year+"-"+month+"-"+day);

break;

}

else{

day++;

System.out.println("明天是:"+year+"-"+month+"-"+day);

break;

}

}

}

}

2. 测试用例设计

利用等价类划分法设计测试用例

输入条件

编号

有效等价类

编号

无效等价类

日期

1

1<=day<=27

10

Day<1

2

闰年2月29

11

闰年2月30

3

平年2月28

12

平年2月29

4

day=30

13

Day=31

5 day=31 14 Day=32

6 12月31 15 12月32

月份

7

1<=month<=12

16

Month<1

17

Month>12

年份

8

1000<=year<=9999

18

Year<1000

19

Year>9999

输入类型

9

输入为Int型

20

除整型外的 任意类型输 入

3. 测试用例执行情况

测试用例编号

输入

预期结果

实际输出

覆盖等价类

(1)

1991-6-20

1991-6-21

1991-6-21

1,7,8,9

(2)

1992-4-30

1992-5-1

1992-5-1

4,7,8,9

(3)

1993-5-31

1993-6-1

1993-6-1

5,7,8,9

(4)

2000-2-29

2000-3-1

2000-3-1

2,7,8,9

(5)

2001-2-28

2001-2-28

2001-2-28

3,7,8,9

(6)

2002-12-31

2003-1-1

2003-1-1

4,7,8,9

(7)

2003-3-0

日期输入有误,请重新输入

日期输入有误,请重新输入

10

(8)

2004-2-30

本月是闰月,请在1-29之间从新输入日期

本月是闰月,请在1-29之间从新输入日期

11

(9)

2005-2-29

本月是二月,请在1-28之间从新输入日期

本月是二月,请在1-28之间从新输入日期

12

(10)

2006-6-31

日期输入有误,请重新输入

日期输入有误,请重新输入

13

(11)

2006-7-32

日期输入有误,请重新输入

日期输入有误,请重新输入

14

(12)

2007-12-32

日期输入有误,请重新输入

日期输入有误,请重新输入

15

(13)

2008-00-1

月份输入有误,请重新输入

月份输入有误,请重新输入

16

(14)

2009-13-23

月份输入有误,请重新输入

月份输入有误,请重新输入

17

(15)

256-2-23

年份输入有误,请重新输入

年份输入有误,请重新输入

18

(16)

10000-3-3

年份输入有误,请重新输入

年份输入有误,请重新输入

19

(17)

!@#¥

出现程序错误

出现程序错误

20

展开阅读全文

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值