eXparity / hamcrest-date

A Java library which provides a suite hamcrest matchers for matching dates, times, and moments in time
BSD 3-Clause "New" or "Revised" License
70 stars 11 forks source link

Test assertions (and results) are Locale specific #21

Closed tnaskali closed 4 years ago

tnaskali commented 6 years ago

When I clone the repo and run mvn test I have multiple Locale-related failures. This is annoying when working on a new feature / fix on a fork.

Example :

canDescribeDate(org.exparity.hamcrest.date.core.format.ZonedDateTimeFormatterTest)  Time elapsed: 0 sec  <<< FAILURE!
java.lang.AssertionError: 
Expected: "Tue, 04 Aug 2015"
     but: was "mar., 04 août 2015"
    at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
    at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
    at org.exparity.hamcrest.date.core.format.ZonedDateTimeFormatterTest.canDescribeDate(ZonedDateTimeFormatterTest.java:25)
stewbis commented 6 years ago

Agreed, that's a pain. I'll raise a fix to pass in the locale so it's anchored to english but will support other locales if they're added.

stewbis commented 4 years ago

All the matchers now support the fluent method atLocale so the Locale used in the matcher errors can be controlled. e.g.

assertThat(LocalDate.now(), after(LocalDate.now().minusDays(1)).atLocale(Locale.EN)