Skip to content

Commit

Permalink
Demote opentest4j between assumption exception classes (fixes #1985)
Browse files Browse the repository at this point in the history
New order of priority:
* org.testng.SkipException
* org.junit.AssumptionViolatedException
* org.opentest4j.TestAbortedException
  • Loading branch information
scordio committed Sep 5, 2020
1 parent 91db723 commit cf65f6a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/assertj/core/api/Assumptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -1295,16 +1295,16 @@ protected static <ASSERTION> Class<? extends ASSERTION> generateAssumptionClass(
}

private static RuntimeException assumptionNotMet(AssertionError assertionError) throws ReflectiveOperationException {
Class<?> assumptionClass = getAssumptionClass("org.opentest4j.TestAbortedException");
Class<?> assumptionClass = getAssumptionClass("org.testng.SkipException");
if (assumptionClass != null) return assumptionNotMet(assumptionClass, assertionError);

assumptionClass = getAssumptionClass("org.testng.SkipException");
assumptionClass = getAssumptionClass("org.junit.AssumptionViolatedException");
if (assumptionClass != null) return assumptionNotMet(assumptionClass, assertionError);

assumptionClass = getAssumptionClass("org.junit.AssumptionViolatedException");
assumptionClass = getAssumptionClass("org.opentest4j.TestAbortedException");
if (assumptionClass != null) return assumptionNotMet(assumptionClass, assertionError);

throw new IllegalStateException("Assumptions require opentest4j, TestNG or JUnit on the classpath");
throw new IllegalStateException("Assumptions require TestNG, JUnit or opentest4j on the classpath");
}

private static Class<?> getAssumptionClass(String className) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/assertj/core/util/AssertionsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.assertj.core.api.ThrowableAssertAlternative;
import org.opentest4j.TestAbortedException;
import org.junit.AssumptionViolatedException;

public class AssertionsUtil {

Expand All @@ -41,7 +41,7 @@ public static ThrowableAssertAlternative<AssertionError> assertThatAssertionErro
}

public static void expectAssumptionNotMetException(ThrowingCallable shouldRaiseError) {
assertThatThrownBy(shouldRaiseError).isInstanceOf(TestAbortedException.class);
assertThatThrownBy(shouldRaiseError).isInstanceOf(AssumptionViolatedException.class);
}

public static Charset getDifferentCharsetFrom(Charset charset) {
Expand Down

0 comments on commit cf65f6a

Please sign in to comment.