Package junit.framework

Examples of junit.framework.AssertionFailedError.initCause()


        }
        if (!expectedException.isAssignableFrom(t.getClass())) {
          // Wrap the unexpected throwable with an explicit message.
          AssertionFailedError assertionError = new AssertionFailedError("Unexpected exception, expected<" +
              expectedException.getName() + "> but was<" + t.getClass().getName() + ">");
          assertionError.initCause(t);
          throw assertionError;
        }
      }
    }
  }
View Full Code Here


        }
        if (!expectedException.isAssignableFrom(ex.getClass())) {
          // Wrap the unexpected throwable with an explicit message.
          AssertionFailedError assertionError = new AssertionFailedError("Unexpected exception, expected <" +
              expectedException.getName() + "> but was <" + ex.getClass().getName() + ">");
          assertionError.initCause(ex);
          throw assertionError;
        }
      }
    }
  }
View Full Code Here

     */
    public static void fail(String msg, Exception e)
            throws AssertionFailedError {

        AssertionFailedError ae = new AssertionFailedError(msg);
        ae.initCause(e);
        throw ae;
    }
} // End class BaseTestCase
View Full Code Here

  }

  static void fail(Throwable cause, Object message) {
    AssertionFailedError assertionFailedError =
        new AssertionFailedError(String.valueOf(message));
    assertionFailedError.initCause(cause);
    throw assertionFailedError;
  }

  public static <K, V> Comparator<Entry<K, V>> entryComparator(
      final Comparator<? super K> keyComparator) {
View Full Code Here

  }

  static void fail(Throwable cause, Object message) {
    AssertionFailedError assertionFailedError =
        new AssertionFailedError(String.valueOf(message));
    assertionFailedError.initCause(cause);
    throw assertionFailedError;
  }

  public static <K, V> Comparator<Entry<K, V>> entryComparator(
      final Comparator<? super K> keyComparator) {
View Full Code Here

    String message = String.format(
        "Error in automated %s of %s\n"
            + "If the class is better tested explicitly, you can add %s() to %sTest",
        description, cls, explicitTestNames.get(0), cls.getName());
    AssertionFailedError error = new AssertionFailedError(message);
    error.initCause(e);
    return error;
  }

  /**
   * Finds the classes not ending with a test suffix and not covered by an explicit test
View Full Code Here

      }
    }
    AssertionFailedError failure =
        new AssertionFailedError("Expected element " + clazz + "." + method
            + " not found in stack trace");
    failure.initCause(e);
    throw failure;
  }

  private ExecutionException getExpectingExecutionException(
      AbstractFuture<String> future) throws InterruptedException {
View Full Code Here

    } catch (ExecutionException e) {
      propagateIfInstanceOf(e.getCause(), ExecutionException.class);
      propagateIfInstanceOf(e.getCause(), CancellationException.class);
      AssertionFailedError error =
          new AssertionFailedError("Unexpected exception");
      error.initCause(e);
      throw error;
    } finally {
      executor.shutdownNow();
      assertTrue(executor.awaitTermination(10, SECONDS));
    }
View Full Code Here

     * turn that back into a failure.
     */
    Handler throwingHandler = new Handler() {
      @Override public void publish(@Nullable LogRecord record) {
        AssertionFailedError error = new AssertionFailedError();
        error.initCause(record.getThrown());
        throw error;
      }

      @Override public void flush() {}

View Full Code Here

        .testNulls();
  }

  private static void failWithCause(Throwable cause, String message) {
    AssertionFailedError failure = new AssertionFailedError(message);
    failure.initCause(cause);
    throw failure;
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.