Skip to content

Commit

Permalink
Change the way test failures are reported
Browse files Browse the repository at this point in the history
If boot fails report it on the first test execution,
then skip all subsequent tests.

Fixes quarkusio#7203
  • Loading branch information
stuartwdouglas committed Feb 15, 2020
1 parent da0cea0 commit b3db957
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class QuarkusTestExtension
private static ClassLoader originalCl;
private static RunningQuarkusApplication runningQuarkusApplication;
private static Path testClassLocation;
private static Throwable firstException; //if this is set then it will be thrown from the very first test that is run, the rest are aborted

private ExtensionState doJavaStart(ExtensionContext context, TestResourceManager testResourceManager) {

Expand Down Expand Up @@ -156,6 +157,14 @@ public void beforeEach(ExtensionContext context) throws Exception {
runningQuarkusApplication.getClassLoader().loadClass(TestScopeManager.class.getName())
.getDeclaredMethod("setup", boolean.class).invoke(null, nativeImageTest);
}
} else {
if (firstException != null) {
Throwable throwable = firstException;
firstException = null;
throw new RuntimeException(throwable);
} else {
throw new TestAbortedException("Boot failed");
}
}
}

Expand All @@ -178,7 +187,7 @@ private ExtensionState ensureStarted(ExtensionContext extensionContext) {
e.addSuppressed(ex);
}
failedBoot = true;
throw e;
firstException = e;
}
}
return state;
Expand All @@ -200,9 +209,6 @@ public void beforeAll(ExtensionContext context) throws Exception {
if (runningQuarkusApplication != null) {
setCCL(runningQuarkusApplication.getClassLoader());
}
if (failedBoot) {
throw new TestAbortedException("Not running test as boot failed");
}
}

@Override
Expand Down Expand Up @@ -233,7 +239,7 @@ public <T> T interceptTestClassConstructor(Invocation<T> invocation,
}
ExtensionState state = ensureStarted(extensionContext);
if (failedBoot) {
return invocation.proceed();
return result;
}
initTestState(extensionContext, state);
return result;
Expand Down

0 comments on commit b3db957

Please sign in to comment.