Re: Discrepancy in current hour
On Mar 20, 6:23 pm, Arved Sandstrom <dces...@hotmail.com> wrote:
Rhino wrote:
[ SNIP ]
If you'd like to see the JUnit tests, I could include them but I'm pret=
ty
sure that there is nothing wrong with them.
It can't hurt - you've asked for feedback concerning testing in general,
and JUnit specifically, and that's a good way to get some.
AHS
Here are the test cases for the three methods that are giving me the
wrong hour. As you can imagine, the hour changes regularly -
hourly ;-) - so I have to keep revising the expectedResult to match.
(This is a much bigger problem with the second and millisecond by the
way! I wonder what a professional test class would do to make it
unnecessary to recode the expected hour, minute, second (or whatever)
by hand all the time....)
------------------------------------
public void testGetCurrentHour12() {
//TODO: why does this method return 9 (PM) when it is actually 8 in
this time zone right now?
int currentHour = dateTimeUtils.getCurrentHour12HourClock();
int expectedHour = 8;
assertTrue("The actual hour (12 hour clock), " + currentHour + ",
does not equal the expected hour, " + expectedHour,
currentHour==expectedHour);
}
public void testGetCurrentHour24() {
//TODO: why does this method return 21 hours (24-hour clock) when it
is actually 20 in this time zone right now?
int currentHour = dateTimeUtils.getCurrentHour24HourClock();
int expectedHour = 20;
assertTrue("The actual hour (24 hour clock), " + currentHour + ",
does not equal the expected hour, " + expectedHour,
currentHour==expectedHour);
}
public void testGetCurrentTime() {
String currentTime = dateTimeUtils.getCurrentTime();
String expectedTime = "20:24:00"; //$NON-NLS-1$
assertTrue("The actual time, " + currentTime + ", does not equal the
expected time, " + expectedTime, currentTime.equals(expectedTime));
}
------------------------------------
Are we agreed that these test cases are okay?
--
Rhino