-
Notifications
You must be signed in to change notification settings - Fork 1k
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
TestNG 7.3.0 breaks AssertJ assumeThat #2352
Comments
Caused by fee81b4 which exposes JUnit classes to the runtime classpath ( |
Please do not expose JUnit and the other dependencies unless strictly necessary. |
As we are going to release AssertJ version 3.17.0 soon, we could introduce a workaround in AssertJ for this issue but it would be great to know if TestNG has any plan to address it. |
I was hoping we could use Thoughts? |
This issue should be addressed in #2358. |
TestNG should not expose JUnit classes by default but both TestNG and JUnit classes are available when the JUnit support feature is used. IMO, It should be fixed in AssertJ first and improve the dependencies of TestNG asap. |
@krmahadevan @juherr as far as I understand, the TestNG dependencies have been fixed in #2358, which is already merged. Would it be an option to release a bugfix version soon? To be precise, on AssertJ side there is nothing wrong right now. We check which classes are in the classpath to derive the underlying test framework, in the following order:
As TestNG exposes JUnit 4 classes transitively, the current AssertJ implementation assumes that the test is running on JUnit 4. The workaround I proposed would check TestNG first and then JUnit. AssertJ 3.17.0 is already out, but we might release 3.17.1 soon due to other issues. However, having a new release from TestNG would be the preference to address this issue. |
Also, as mentioned by @joel-costigliola, it would be interesting to know if there is any plan on adopting opentest4j. |
Thanks for the details. I don't see yet the emergency of a TestNG release. I think the logic is a bit more complicate:
No current plan :( |
@juherr sorry, I misunderstood your previous message and I was focusing only on the transitive dependency aspect. I got only now that both frameworks together is a proper use case if the user decides to have both in the classpath. I will then change the order of AssertJ checks. |
Would you be interested in a PR about it? |
@juherr @cbeust - The link https://github.com/ota4j-team/opentest4j#projects-already-contacted says TestNG has been contacted regarding this. Are you folks aware of this ? I don't recall seeing any mail on this on the TestNG dev users list. @scordio - Maybe you can create a PR (so the technical work related to moving towards this would be done), but we need to get a confirmation from @cbeust on what the plans are for this. @juherr - WDYT ? |
Yes, we were contacted by mail years ago but without enough free time to contribute.
It's adding a new dependency and I'm not sure to understand the value-add of the 6 classes but at the same time, it is not a big deal if it can help someone.
+1, I let the final words for @cbeust |
I just checked opentest4j and the project has had a handful of commits over the past two years, so it looks pretty dead. What's the advantage of supporting it? |
I think it's just a bunch of interfaces/abstract classes, so there shouldn't be the need for lots of development. If TestNG implemented those interfaces / extended those classes, tools like AssertJ could simplify the code base. |
I wouldn't say it's dead, it's just there was no need of so much activity. The main advantage I see is in the handling of the cases mentioned by @juherr:
Having the same exception thrown by both TestNG and JUnit would simplify the matrix of all the possible cases that libraries like AssertJ need to handle. |
@scordio confirmed. Fails with TestNG 7.3.0 and AssertJ 3.17.0, fixed with 7.3.0 / 3.17.1. |
@C-Otto - Can we close this issue since its now taken care of at AssertJ side ? |
TestNG Version
7.3.0
Expected behavior
Using AssertJ's
org.assertj.core.api.Assumptions.assumeThat
method should produce aorg.testng.SkipException
, skipping the test.Actual behavior
The code in
Assumptions
throwsorg.junit.AssumptionViolatedException
instead. This exception is not supported by TestNG, causing a test failure instead of a skipped test.This is because TestNG includes JUnit 4.12, which is detected by
Assumptions
.Is the issue reproductible on runner?
Test case sample
Gradle:
implementation 'org.assertj:assertj-core:3.12.1'
The text was updated successfully, but these errors were encountered: