FEST
  1. FEST
  2. FEST-393

Built-in assertions for Date and Calendar types

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: FEST-Assert 1.3
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Making assertions on Date and Calendar instances is very annoying, basically you need to extract each field and make assertions on primitive values. It would be great to have DateAssert built-in (I know I can implement one myself using AssertExtension, but these are so common types). Typical use cases:

      assertThat(date).hasYear(2010); //isYear name better?
      assertThat(date).after(otherDate);
      assertThat(date).hasHour(18).hasMinute(20);
      assertThat(date).hasMonth(Calendar.APRIL);
      assertThat(date).isInThePast();

      The same set of assertions (the above ones are just examples) should be available for Calendar instances (probably the same assert with conversion from one type to another would be sufficient). Decent error messages (i.e. using SimpleDateFormat) are necessary as toString() of Date and especially GregorianCalendar aren't very useful.

        Activity

        Hide
        Tomasz Nurkiewicz added a comment - - edited

        Another useful methods:

        assertThat(date).between(startDate).and(endDate); //inclusive/exclusive versions?
        assertThat(date).closeTo(otherDate, /*tolerance*/);  //tolerance specified as number of milliseconds or TimeUnit + value

        Possible interface of such an assert can be found at: CalendarAssert.

        Show
        Tomasz Nurkiewicz added a comment - - edited Another useful methods: assertThat(date).between(startDate).and(endDate); //inclusive/exclusive versions? assertThat(date).closeTo(otherDate, /*tolerance*/); //tolerance specified as number of milliseconds or TimeUnit + value Possible interface of such an assert can be found at: CalendarAssert .
        Hide
        Joel Costigliola added a comment -

        We already have FEST-63 to adress date assertions so I will make this one as a duplicate but will include your interesting suggestions.
        Thanks for reporting this !

        Show
        Joel Costigliola added a comment - We already have FEST-63 to adress date assertions so I will make this one as a duplicate but will include your interesting suggestions. Thanks for reporting this !
        Hide
        Joel Costigliola added a comment -

        adding your suggestions to FEST-63 and make this one a duplicate of it.

        Show
        Joel Costigliola added a comment - adding your suggestions to FEST-63 and make this one a duplicate of it.

          People

          • Assignee:
            Unassigned
            Reporter:
            Tomasz Nurkiewicz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: