实验目的
(1)掌握应用黑盒测试技术进行测试用例设计。
(2)掌握对测试用例进行优化设计方法。
实验内容
日期问题
测试以下程序:该程序有三个输入变量month、day、year(month、day和year均为整数值,并且满足:1≤month≤12、1≤day≤31和1900≤ year ≤2050),分别作为输入日期的月份、日、年份,通过程序可以输出该输入日期在日历上隔一天的日期。例如,输入为 2004 年11月30日,则该程序的输出为2004年12月1日。
(1)划分等价类,按照等价类划分法设计测试用例;
(2)编写nextDate函数;
(3)掌握Junit4的用法,使用Junit4测试nextDate函数。
JUnit4是JUnit框架有史以来的最大改进,其主要目标便是利用Java5的Annotation特性简化测试用例的编写。掌握Junit4定义 的一些常见
Annotations:
org.junit.Test
org.junit.Before
org.junit.After
org.junit.BeforeClass
org.junit.AfterClass
org.junit.Ignore
org.junit.runner.RunWith
org.junit.runners.Suite.SuiteClasses
org.junit.runners.Parameterized.Parameters:
实验要求
(1)根据题目要求编写测试用例;
(2)准备nextDate函数,使用Junit4测试执行测试;
(3)撰写实验报告。
测试用例
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
public static void main(String args[]) throws IOException {
int year, month, day;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while (true) {