assertj: Assumptions are broken in JUnit4 when opentest4j is in the classpath with 3.17.1

Summary

#1983 causes assumptions to fail instead of ignoring the test in edge cases.

This only occurs with JUnit4 when opentest4j is in the classpath, e.g. as transitive dependency from other test utilities like Json-Unit.

JUnit4 does not recognize org.opentest4j.TestAbortedException as expected and fails.

Example

I created a test case for Json-Unit.

package net.javacrumbs.jsonunit.test.junit4;

import org.assertj.core.api.Assumptions;
import org.junit.Test;

public class AssumptionsWithAssertJTest {
    @Test
    public void shouldBeIgnoredButFails() {
        Assumptions.assumeThat("Test").isEqualTo("NotEqualToTest");
    }
}

See also https://github.com/lukas-krecan/JsonUnit/issues/276

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (17 by maintainers)

Most upvoted comments

Thank you very much for this amazingly fast response.

Option 3 would be the best but timeline and feasibility can vary from project to project.

You are right in both parts. In our case there are around 50 (micro) services that are based on JUnit4 and there are hundreds more at developing customers that rely on our tooling. It’s really a long term task to upgrade. Luckily cases like this are rare compared to total amount of tests.

1. Revert the fix done in 3.17.1 but I'm not super keen to support a library that is being replaced by JUnit 5 TBH.

The important part of #1983 was to have TestNG winning over JUnit 4. We might also push down the priority of opentest4j. If we go with the following order:

  1. org.testng.SkipException
  2. org.junit.AssumptionViolatedException
  3. org.opentest4j.TestAbortedException

TestNG with JUnit 4 would still work and JsonUnit should also work.

However, I would vote for option 2 as this would make JsonUnit work nicely with both JUnit 4 and 5 use cases. Keen to contribute in case @lukas-krecan agrees.

Option 3 would be the best but timeline and feasibility can vary from project to project.