-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Reset junit test's extension failed state for each test class #38127
Reset junit test's extension failed state for each test class #38127
Conversation
6213d96
to
86bb694
Compare
// we reload the test resources if we changed test class and if we had or will have per-test test resources | ||
boolean reloadTestResources = !Objects.equals(extensionContext.getRequiredTestClass(), currentJUnitTestClass) | ||
boolean reloadTestResources = resetFailedState |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of deceiving in appearances TBH because whether or not reloadTestResources
is set to true, is not theorically equivalent to setting resetFailedState
to true
.
So I would just keep this line the way it was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to avoid code duplication what I would do is introduce 👍🏼
boolean isNewTestClass = !Objects.equals(extensionContext.getRequiredTestClass(), currentJUnitTestClass);
and use that to set resetFailedState
and reloadTestResources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Done.
// we reset the failed state if we changed test class and the new test class is not a nested class | ||
boolean resetFailedState = !Objects.equals(extensionContext.getRequiredTestClass(), currentJUnitTestClass) | ||
&& !isNested(currentJUnitTestClass, extensionContext.getRequiredTestClass()); | ||
if (resetFailedState && state != null) { | ||
state.setTestFailed(null); | ||
currentJUnitTestClass = extensionContext.getRequiredTestClass(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments here as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This comment has been minimized.
This comment has been minimized.
86bb694
to
9f8096e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This comment has been minimized.
This comment has been minimized.
The CI somehow skips to build locales and locales-app, the more I look at it the more it feels unrelated to me. |
The fact that we don't get any passing JVM build is troubling |
This comment has been minimized.
This comment has been minimized.
9f8096e
to
82c2a1c
Compare
This comment has been minimized.
This comment has been minimized.
And it's also persistent so it's clearly related to the patch. |
82c2a1c
to
481e6af
Compare
It looks a bit related to what I was struggling with here: #36356 |
481e6af
to
4977764
Compare
Interestingly, the tests fail even if I don't actually touch the state (zakkak@4977764)! |
f2b076c
to
561ac5e
Compare
561ac5e
to
24de35e
Compare
24de35e
to
4e7e9d8
Compare
So the tests are failing even with just the following patch: diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusIntegrationTestExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusIntegrationTestExtension.java
index 61924375753..0c1c1fdccad 100644
--- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusIntegrationTestExtension.java
+++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusIntegrationTestExtension.java
@@ -146,8 +146,14 @@ private QuarkusTestExtensionState ensureStarted(ExtensionContext extensionContex
QuarkusTestExtensionState state = getState(extensionContext);
Class<? extends QuarkusTestProfile> selectedProfile = findProfile(testClass);
boolean wrongProfile = !Objects.equals(selectedProfile, quarkusTestProfile);
+ // we reset the failed state if we changed test class
+ boolean isNewTestClass = !Objects.equals(extensionContext.getRequiredTestClass(), currentJUnitTestClass);
+ // if (isNewTestClass && state != null) {
+ // state.setTestFailed(null);
+ // currentJUnitTestClass = extensionContext.getRequiredTestClass();
+ // }
// we reload the test resources if we changed test class and if we had or will have per-test test resources
- boolean reloadTestResources = !Objects.equals(extensionContext.getRequiredTestClass(), currentJUnitTestClass)
+ boolean reloadTestResources = isNewTestClass
&& (hasPerTestResources || QuarkusTestExtension.hasPerTestResources(extensionContext));
if ((state == null && !failedBoot) || wrongProfile || reloadTestResources) {
if (wrongProfile || reloadTestResources) {
diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java
index 4002b9139cf..22533be7a90 100644
--- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java
+++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java
@@ -586,10 +586,15 @@ private QuarkusTestExtensionState ensureStarted(ExtensionContext extensionContex
QuarkusTestExtensionState state = getState(extensionContext);
Class<? extends QuarkusTestProfile> selectedProfile = getQuarkusTestProfile(extensionContext);
boolean wrongProfile = !Objects.equals(selectedProfile, quarkusTestProfile);
+ // we reset the failed state if we changed test class and the new test class is not a nested class
+ boolean isNewTestClass = !Objects.equals(extensionContext.getRequiredTestClass(), currentJUnitTestClass)
+ && !isNested(currentJUnitTestClass, extensionContext.getRequiredTestClass());
+ // if (isNewTestClass && state != null) {
+ // state.setTestFailed(null);
+ // currentJUnitTestClass = extensionContext.getRequiredTestClass();
+ // }
// we reload the test resources if we changed test class and the new test class is not a nested class, and if we had or will have per-test test resources
- boolean reloadTestResources = !Objects.equals(extensionContext.getRequiredTestClass(), currentJUnitTestClass)
- && !isNested(currentJUnitTestClass, extensionContext.getRequiredTestClass())
- && (hasPerTestResources || hasPerTestResources(extensionContext));
+ boolean reloadTestResources = isNewTestClass && (hasPerTestResources || hasPerTestResources(extensionContext));
if ((state == null && !failedBoot) || wrongProfile || reloadTestResources) {
if (wrongProfile || reloadTestResources) {
if (state != null) { See https://github.com/zakkak/quarkus/actions/runs/7538846221 and 4e7e9d8 So it feels like the issue is not related to the change itself but rather to how we run the tests. @Karm does the error ring any bells to you? It looks like the locales test fails to properly build the
Interestingly, the
while normally it looks like:
|
I will take a quick look |
Hopefully #38238 should fix it |
4e7e9d8
to
929638a
Compare
Thanks @geoand, I am giving it a go in https://github.com/zakkak/quarkus/actions/runs/7556725913 |
🤞🏼 |
@geoand it works! |
🥂 |
929638a
to
db505dd
Compare
This comment has been minimized.
This comment has been minimized.
db505dd
to
a05210a
Compare
This comment has been minimized.
This comment has been minimized.
😱 |
a05210a
to
205ac74
Compare
This comment has been minimized.
This comment has been minimized.
Try rebasing onto |
Fix Quarkus TestExtensions to avoid mistakenly transferring the failed state of one test class to the other. Closes quarkusio#37809
205ac74
to
bc7f63b
Compare
✔️ The latest workflow run for the pull request has completed successfully. It should be safe to merge provided you have a look at the other checks in the summary. You can consult the Develocity build scans. |
Fix Quarkus TestExtensions to avoid mistakenly transferring the failed
state of one test class to the other.
Closes #37809
Tests with Mandrel 24.0-dev https://github.com/graalvm/mandrel/actions/runs/7476057769