/** * {@inheritDoc} */ @Override public String toString() { return getMessage(); } }
/** * Returns Class.forName for {@code className} using the current thread's class loader. * If the current thread does not have a class loader, falls back to the class loader for * {@link Classes}. * * @param className Name of the class. * @throws ClassNotFoundException */ public static Class<?> getClass(String className) throws ClassNotFoundException { return getClass(className, Classes.class); }
private static boolean isTestFrameworkMethod(String methodName) { return isMatchingMethod(methodName, TEST_FRAMEWORK_METHOD_NAME_PREFIXES) && !isMatchingMethod(methodName, TEST_FRAMEWORK_TEST_METHOD_NAME_PREFIXES); }
/** * If called with an expression evaluating to {@code false}, the test will halt and be ignored. * * @param b If <code>false</code>, the method will attempt to stop the test and ignore it by * throwing {@link AssumptionViolatedException}. * @param message A message to pass to {@link AssumptionViolatedException}. */ public static void assumeTrue(String message, boolean b) { if (!b) throw new AssumptionViolatedException(message); }
/** * Asserts that two float arrays are equal. If they are not, an * {@link AssertionError} is thrown with the given message. * * @param message the identifying message for the {@link AssertionError} (<code>null</code> * okay) * @param expecteds float array with expected values. * @param actuals float array with actual values */ public static void assertArrayEquals(String message, float[] expecteds, float[] actuals, float delta) throws ArrayComparisonFailure { new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals); }
/** * Asserts that two object arrays are equal. If they are not, an * {@link AssertionError} is thrown with the given message. If * <code>expecteds</code> and <code>actuals</code> are <code>null</code>, * they are considered equal. * * @param message the identifying message for the {@link AssertionError} (<code>null</code> * okay) * @param expecteds Object array or array of arrays (multi-dimensional array) with * expected values. * @param actuals Object array or array of arrays (multi-dimensional array) with * actual values */ private static void internalArrayEquals(String message, Object expecteds, Object actuals) throws ArrayComparisonFailure { new ExactComparisonCriteria().arrayEquals(message, expecteds, actuals); }
/** * Construct a new <code>ArrayComparisonFailure</code> with an error text and the array's * dimension that was not equal * * @param cause the exception that caused the array's content to fail the assertion test * @param index the array position of the objects that are not equal. * @see Assert#assertArrayEquals(String, Object[], Object[]) */ public ArrayComparisonFailure(String message, AssertionError cause, int index) { this.fMessage = message; this.fCause = cause; initCause(fCause); addDimension(index); }
public TextListener(JUnitSystem system) { this(system.out()); }
/** * Construct a new <code>ArrayComparisonFailure</code> with an error text and the array's * dimension that was not equal * * @param cause the exception that caused the array's content to fail the assertion test * @param index the array position of the objects that are not equal. * @see Assert#assertArrayEquals(String, Object[], Object[]) */ public ArrayComparisonFailure(String message, AssertionError cause, int index) { fMessage = message; fCause = cause; addDimension(index); }
/** * Asserts that two arrays are equal, according to the criteria defined by * the concrete subclass. If they are not, an {@link AssertionError} is * thrown with the given message. If <code>expecteds</code> and * <code>actuals</code> are <code>null</code>, they are considered equal. * * @param message the identifying message for the {@link AssertionError} ( * <code>null</code> okay) * @param expecteds Object array or array of arrays (multi-dimensional array) with * expected values. * @param actuals Object array or array of arrays (multi-dimensional array) with * actual values */ public void arrayEquals(String message, Object expecteds, Object actuals) throws ArrayComparisonFailure { arrayEquals(message, expecteds, actuals, true); }
/** * An assumption exception with the given message and a cause. * * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead. */ @Deprecated public AssumptionViolatedException(String assumption, Throwable e) { this(assumption, false, null, null); initCause(e); }
private String readStacktrace(Throwable throwable) { return Throwables.getStacktrace(throwable); }
/** * Constructs a new {@code ParentRunner} that will run the {@code TestClass}. * * @since 4.13 */ protected ParentRunner(TestClass testClass) throws InitializationError { this.testClass = notNull(testClass); validate(); }
/** * Asserts that two double arrays are equal. If they are not, an * {@link AssertionError} is thrown with the given message. * * @param message the identifying message for the {@link AssertionError} (<code>null</code> * okay) * @param expecteds double array with expected values. * @param actuals double array with actual values */ public static void assertArrayEquals(String message, double[] expecteds, double[] actuals, double delta) throws ArrayComparisonFailure { new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals); }
public TextListener(JUnitSystem system) { this(system.out()); }
/** * {@inheritDoc} */ @Override public String toString() { return getMessage(); } }
private static boolean isReflectionMethod(String methodName) { return isMatchingMethod(methodName, REFLECTION_METHOD_NAME_PREFIXES); }
/** * Gets the printed form of the exception and its stack trace. */ public String getTrace() { return Throwables.getStacktrace(getException()); }
/** * Asserts that two double arrays are equal. If they are not, an * {@link AssertionError} is thrown with the given message. * * @param message the identifying message for the {@link AssertionError} (<code>null</code> * okay) * @param expecteds double array with expected values. * @param actuals double array with actual values * @param delta the maximum delta between <code>expecteds[i]</code> and * <code>actuals[i]</code> for which both numbers are still * considered equal. */ public static void assertArrayEquals(String message, double[] expecteds, double[] actuals, double delta) throws ArrayComparisonFailure { new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals); }
/** * Asserts that two float arrays are equal. If they are not, an * {@link AssertionError} is thrown with the given message. * * @param message the identifying message for the {@link AssertionError} (<code>null</code> * okay) * @param expecteds float array with expected values. * @param actuals float array with actual values * @param delta the maximum delta between <code>expecteds[i]</code> and * <code>actuals[i]</code> for which both numbers are still * considered equal. */ public static void assertArrayEquals(String message, float[] expecteds, float[] actuals, float delta) throws ArrayComparisonFailure { new InexactComparisonCriteria(delta).arrayEquals(message, expecteds, actuals); }