views:

54

answers:

3

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 me 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

A: 

You could for example compare the string reprensetations.

DerMike
A: 

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.

Andreas_D
+2  A: 

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());
mlk
What's this `iso()` method??
Carl Smotricz
Ah, yeah sorry. I have a static method that that simply takes a ISO 8601 formatted date as a string and returns it as a date. I will Updated the answer to remove it.
mlk