Software Testing (iii)--parameterized test cases (Nextday.java)

Source: Internet
Author: User

Import Staticorg.junit.assert.*;ImportJava.lang.reflect.Array;Importjava.util.Arrays;Importjava.util.Collection;Importorg.junit.Test;ImportOrg.junit.runner.RunWith;Importorg.junit.runners.Parameterized;Importorg.junit.runners.Parameterized.Parameters; //This is not rare @RunWith (Value = Parameterized.class) Public classNextdaytest {PrivateDate expected; PrivateDate value; @Parameters  Public StaticCollection<object[]>gettestparameters () {//Valid equivalence classesDate D1 =NewDate (5, 14, 2014); Date D2=NewDate (5, 13, 2014); //is a negative date//Date D3 = new Date (5, 0,);//Date D4 = new Date (5,-1, 2014); //is zero date//date d5 = new Date (5, 1,);//Date d6 = new Date (5, 0, 2014); //number 31stDate D7 =NewDate (8, 31, 2015); Date D8=NewDate (8, 30, 2015); Date D9=NewDate (7, 31, 2014); Date D10=NewDate (7, 30, 2014); Date D11=NewDate (7, 1, 2013); Date D12=NewDate (6, 30, 2013); //Leap YearDate D13 =NewDate (3, 1, 2004); Date D14=NewDate (2, 29, 2004); Date D15=NewDate (2, 29, 2004); Date D16=NewDate (2, 28, 2004); //400 years is a leap yearDate D17 =NewDate (3, 1, 2000); Date D18=NewDate (2, 29, 2000); Date D19=NewDate (3, 1, 2013); Date d20=NewDate (2, 28, 2013); //divisible by 4, not divisible by 100.Date D23 =NewDate (3, 1, 2100); Date d24=NewDate (2, 28, 2100); //to the second yearDate D21 =NewDate (1, 1, 2014); Date D22=NewDate (12, 31, 2013); //Next one monthsDate D25 =NewDate (1, 31, 2013); Date d26=NewDate (1, 30, 2013); Date D27=NewDate (2, 1, 2013); Date D28=NewDate (1, 31, 2013); Date d29=NewDate (4, 1, 2014); Date D30=NewDate (3, 31, 2014); Date D31=NewDate (5, 1, 2014); Date D32=NewDate (4, 30, 2014); Date d33=NewDate (6, 1, 2014); Date D34=NewDate (5, 31, 2014); Date D35=NewDate (7, 1, 2014); Date D36=NewDate (6, 30, 2014); Left is expected, right is value object[][] Date=Newobject[][] {{d1, d2},//{d3, d4},//{d5, d6},{d7, D8}, {D9, D10}, {D11, D12}, {D13, D14},                 {D15, D16}, {D17, D18}, {D19, d20}, {D21, D22}, {D23, d24},                {d25, d26}, {d27, d28}, {d29, D30}, {d31, d32},        {d33, D34}, {D35, d36}}; returnarrays.aslist (date);    }//constructor do not omit!  Publicnextdaytest (date expected, date value) {Super();  This. Expected =expected;  This. Value =value; } @Test Public voidTestnextday () {assertequals (expected, Nextday.nextday (value)); }}

Software Testing (iii)--parameterized test cases (Nextday.java)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.