@Test
 public void should_create_error_message() {
   String message = factory.create(new TestDescription("Test"));
   assertEquals(
       "[Test] \nExpecting\n <\"Yoda\">\nto have the same class as:\n <10L>(<java.lang.Long>) \nbut its class was:<java.lang.String>",
       message);
 }
 @Test
 public void should_create_error_message() {
   String message = factory.create(new TextDescription("Test"));
   assertEquals(
       "[Test] \nExpecting elements:\n<[\"Leia\"]>\n of \n<[\"Yoda\", \"Luke\", \"Leia\"]>\n to have <jedi power>",
       message);
 }
Exemplo n.º 3
0
 /**
  * Creates a <code>{@link AssertionError}</code> following this pattern:
  *
  * <ol>
  *   <li>creates a <code>{@link AssertionError}</code> using <code>
  *       {@link AssertionInfo#overridingErrorMessage()}</code> as the error message if such value
  *       is not {@code null}, or
  *   <li>uses the given <code>{@link ErrorMessageFactory}</code> to create the detail message of
  *       the <code>{@link AssertionError}</code>, prepending the value of <code>
  *       {@link AssertionInfo#description()}</code> to the error message
  * </ol>
  *
  * @param info contains information about the failed assertion.
  * @param message knows how to create detail messages for {@code AssertionError}s.
  * @return the created <code>{@link AssertionError}</code>.
  */
 public AssertionError failure(AssertionInfo info, ErrorMessageFactory message) {
   AssertionError error = failureIfErrorMessageIsOverridden(info);
   if (error != null) return error;
   AssertionError assertionError =
       new AssertionError(message.create(info.description(), info.representation()));
   removeAssertJRelatedElementsFromStackTraceIfNeeded(assertionError);
   printThreadDumpIfNeeded();
   return assertionError;
 }