Esempio n. 1
0
 public AssertionError failureIfErrorMessageIsOverridden(AssertionInfo info) {
   String overridingErrorMessage = info.overridingErrorMessage();
   return isNullOrEmpty(overridingErrorMessage)
       ? null
       : failure(
           MessageFormatter.instance()
               .format(info.description(), info.representation(), overridingErrorMessage));
 }
 @Test
 public void should_create_error_with_StandardRepresentation() {
   Description description = new TestDescription("Test");
   String formattedMessage = "[Test] Hello Yoda";
   when(formatter.format(
           eq(description), any(StandardRepresentation.class), eq("Hello %s"), eq("Yoda")))
       .thenReturn(formattedMessage);
   assertThat(factory.create(description)).isEqualTo(formattedMessage);
 }
 @Test
 public void should_implement_toString() {
   Description description = new TestDescription("Test");
   Representation representation = new StandardRepresentation();
   String formattedMessage = "[Test] Hello Yoda";
   when(formatter.format(description, representation, "Hello %s", "Yoda"))
       .thenReturn(formattedMessage);
   assertThat(factory.create(description, representation)).isEqualTo(formattedMessage);
 }