Skip to content

Commit

Permalink
Merge pull request #38127 from zakkak/2024-01-10-reset-junit-state-fo…
Browse files Browse the repository at this point in the history
…r-each-test-class

Reset junit test's extension failed state for each test class
  • Loading branch information
geoand authored Jan 19, 2024
2 parents 9809d57 + bc7f63b commit b56e918
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b56e918

Please sign in to comment.