测试失败,除调试模式外

时间:2019-03-13 08:50:32

标签: mockito powermockito spring-boot-test

我要测试以下方法:

public static boolean isWithinRange(Date date, Date startDate, Date endDate) {
    return !(date.before(startDate) || date.after(endDate));
}

我的测试是:

@Test
public void isWithinRangeTest() {
    Calendar calendarTest = Calendar.getInstance();
    calendarTest.set(1991, Calendar.JANUARY, 30, 14, 1, 30);

    Calendar calendarStartDate = Calendar.getInstance();
    calendarStartDate.set(1991, Calendar.JANUARY, 30, 13, 0, 0);

    Calendar calendarEndDate = Calendar.getInstance();
    calendarEndDate.set(1991, Calendar.JANUARY, 30, 20, 0, 0);

    // All previous asserts are OK

    calendarTest.set(1991, Calendar.JANUARY, 30, 13, 0, 0);
    assertTrue(DateUtils.isWithinRange(calendarTest.getTime(), calendarStartDate.getTime(), calendarEndDate.getTime()));
}

我的问题是我在运行测试(运行模式)时测试失败,但是在调试模式下可以。 我不明白为什么。你有什么想法吗?

0 个答案:

没有答案