开发者

Gregorian Calendar - Document based testing

After doing JUnit i am doing some document based testing that has the following items in a table

Input Variables - Expected Outcome - Actual Outcome ..... Pass or Fail ....

If i pass my method a date and a time

"01AUG07" "14:40" the method should return 开发者_如何学Gome a gregorian calander which it does

how can i check that it has created the correct one?

thanks

unsure which to pick as the best becuase i dont no which is - i used miks and it worked.

thanks guys


Create a GregorianCalendar with the expect value and compare them. I'd use SimpleDateFormat and the setTime method.

GregorianCalendar expected = new GregorianCalendar();
expected.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm").parse("2007-08-01 14:40"));

SystemUnderTest subject = SystemUnderTest();

assertEquals(expected, subject.method());


You could for example compare the string reprensetations.


I'd calculate the use both 'textual' and their equivalent millisecond values for my test input and compare those milliseconds as expected values with the values that I get with the Calendar#getTimeInMillis.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜