使用等价类划分法以及Junit的参数化测试,测试nextDate函数

需求

日期问题

测试以下程序:该程序有三个输入变量 month、day、year (month、day 和 year 均为整数值,并且满足:1 ≤ months ≤ 12、1 ≤ days ≤ 31 和 1900 ≤ year ≤ 2050),分别作为输入日期的月份、日、年份,通过程序可以输出该输入日期在日历上隔天的日期。例如,输入为 2004 年 11 月 30 日,则该程序的输出为 2004 年 12 月 1 日。

实现

(1)根据题目要求编写测试用例

1)划分等价类并编

3)为每一个无效等价类至少设计一个测试用例

测试类

import org.junit.After;import org.junit.Assert;import org.junit.Before;import org.junit.Test;import org.junit.runner.RunWith;import org.junit.runners.Parameterized;import java.util.Arrays;import java.util.Collection;@RunWith(Parameterized.class)public class DateTest {    private String input1;    private String input2;    private String input3;    private String expected;    @Parameterized.Parameters    @SuppressWarnings("unchecked")    public static Collection prepareData(){Object [][] object = { // 有效等价类 {"2016","2","29","下一天是2016年3月1日!"}, {"2017","1","28","下一天是2017年1月29日!"}, {"2017","1","31","下一天是2017年2月1日!"}, {"2017",

                                                        

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年3月3日
下一篇 2022年3月3日

相关推荐