Skip to content

Commit

Permalink
Merge pull request quarkusio#9982 from jaikiran/qk-9971
Browse files Browse the repository at this point in the history
Prevent a NPE and report the actual cause of boot failure in QuarkusTestExtension
  • Loading branch information
geoand authored Jun 14, 2020
2 parents e055e95 + 04ff1a6 commit 399e16b
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,8 @@ public void beforeEach(ExtensionContext context) throws Exception {
setCCL(original);
}
} else {
if (firstException != null) {
Throwable throwable = firstException;
firstException = null;
throw new RuntimeException(throwable);
} else {
throw new TestAbortedException("Boot failed");
}
throwBootFailureException();
return;
}
}

Expand Down Expand Up @@ -331,6 +326,16 @@ private static ClassLoader setCCL(ClassLoader cl) {
return original;
}

private void throwBootFailureException() throws Exception {
if (firstException != null) {
Throwable throwable = firstException;
firstException = null;
throw new RuntimeException(throwable);
} else {
throw new TestAbortedException("Boot failed");
}
}

@Override
public void beforeAll(ExtensionContext context) throws Exception {
if (isNativeTest(context)) {
Expand Down Expand Up @@ -376,6 +381,10 @@ public void interceptBeforeAllMethod(Invocation<Void> invocation, ReflectiveInvo
return;
}
ensureStarted(extensionContext);
if (failedBoot) {
throwBootFailureException();
return;
}
runExtensionMethod(invocationContext, extensionContext);
invocation.skip();
}
Expand Down

0 comments on commit 399e16b

Please sign in to comment.