@Test public void should_fail_as_seconds_fields_are_different() { thrown.expectAssertionError( "%nExpecting:%n" + " <00:00:01Z>%n" + "to have same hour, minute and second as:%n" + " <00:00:00.999999999Z>%n" + "but had not."); assertThat(refOffsetTime).isEqualToIgnoringNanos(refOffsetTime.minusNanos(1)); }
@Test public void should_fail_as_minutes_fields_are_different_even_if_time_difference_is_less_than_a_minute() { try { assertThat(refOffsetTime).hasSameHourAs(refOffsetTime.minusNanos(1)); } catch (AssertionError e) { assertThat(e) .hasMessage( format( "%n" + "Expecting:%n" + " <23:00Z>%n" + "to have same hour as:%n" + " <22:59:59.999999999Z>%n" + "but had not.")); return; } failBecauseExpectedAssertionErrorWasNotThrown(); }