The following example doesn't work with TestNG 6.8.8, JMockit 1.12 and Java 1.8.0_20.
public class DateUser {
public static boolean isLunchTime() {
int hour = LocalDateTime.now().getHour();
return hour >= 12 && hour <= 14;
}
}
public class DateUserTest {
@Test
public void shouldReturnTrueFor12h(@Mocked LocalDateTime dateTime) {
new Expectations() {{
LocalDateTime.now(); result = dateTime;
dateTime.getHour(); result = 12;
}};
boolean isLunchTime = DateUser.isLunchTime();
assertThat(isLunchTime).isTrue();
}
}
It works only with JUnit.
The following example doesn't work with TestNG 6.8.8, JMockit 1.12 and Java 1.8.0_20.
It works only with JUnit.