-
-
Notifications
You must be signed in to change notification settings - Fork 683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assumptions are broken in JUnit4 when opentest4j is in the classpath with 3.17.1 #1985
Comments
Thanks for raising this @JoergSiebahn. @lukas-krecan is there a particular reason that JsonUnit is providing opentest4j as a transitive dependency instead of being optional? |
JsonUnit supports multiple modes of operation, it can work as standalone assertion library, as Hamcrest macher or as an extension of AssertJ. In some scenarios it throws Introduced to implement this lukas-krecan/JsonUnit#146 |
The ideal fix would be for JUnit4 to support Possible way forward
|
The important part of #1983 was to have TestNG winning over JUnit 4. We might also push down the priority of opentest4j.
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. |
I can do 2. but I am not sure if it's the only case when people have opentest4j in the classpath v JUnit 4. |
That would be awesome, thanks!
We will have the same issue if another testing library strongly depends on opentest4j, how likely is hard to say so I would not worry too much about that and wait for someone to raise an issue. |
I'm ok to follow @scordio suggestion and change the order assumption exception, it's pragmatic solution that does not require any changes to JsonUnit. |
I guess we can do both, I have already made opentest4j optional in JsonUnit, will release it soon. |
@joel-costigliola change applied, shall we go with a 3.17.2 release? |
Also, JsonUnit 2.19.0 has been released. Thanks @lukas-krecan! |
can do 3.17.2 |
Thank you very much for this amazingly fast response.
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. |
@JoergSiebahn @lukas-krecan @scordio I have upgraded to AssertJ 3.17.2, and my tests failed. :(
AssertJ 3.17.2 throws |
Hi @asolntsev, could you share some more details about why both JUnit 4 and TestNG appear in the classpath, but tests are running with JUnit 4? BTW your issue is more related to #1961 rather than this issue. |
@scordio I am developing Selenide - a library for UI tests. It provides several rules/listeners for JUnit4, JUnit5 and TestNG. That's why it must have junit4.jar, junit5.jar, testng.jar in classpath. A better solution would be to extract those rules/listeners to separate submodules with their own classpaths, but it means more work for us... :) |
If I understand it correctly, it is an issue only for Selenide own tests as JUnit 4, 5 and TestNG are not transitive dependencies. We are trying to satisfy the use cases for the majority of the users and your use case might be tough to be covered without breaking the others. The current priority order of the assumption exceptions can be found in the breaking changes section of the release notes: https://assertj.github.io/doc/#assertj-core-3-17-2-release-notes If splitting the project into modules is not an option, there might be different strategies to have proper testing:
|
@scordio Don't bother too much :) Ideally, libraries like AssertJ should not depend on JUnit, TestNG or any other testing libraries. Currently you are supporting only JUnit and TestNG, but there may be hundreds of other libraries... It's just not possible to support all of them. |
@asolntsev thanks for sharing, this helps us to understand how much the use case matrix is growing 🙂 AssertJ has to depend on the underlying test engine due to the fluent assumptions, which must throw exceptions understandable by the test engine itself. Ideally, there would be no issue to handle those cases if all the test engines would adopt opentest4j. Unfortunately, this is not the case yet, although with TestNG we started to talk about it in testng-team/testng#2352. |
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.
See also lukas-krecan/JsonUnit#276
The text was updated successfully, but these errors were encountered: