Track exceptions caused by invalid test bundle in test report
@@ -90,6 +90,7 @@ public class JunitRunner extends AbstractComponent implements TestRunner {
if (execution != null && !execution.isDone()) {
throw new IllegalStateException("Test execution already in progress");
}
+ try {
testRuntimeProvider.initialize(testConfig);
Optional<Bundle> testBundle = findTestBundle();
if (testBundle.isEmpty()) {
@@ -100,9 +101,18 @@ public class JunitRunner extends AbstractComponent implements TestRunner {
if (testDescriptor.isEmpty()) {
throw new RuntimeException("Could not find test descriptor");
}
- List<Class<?>> testClasses = loadClasses(testBundle.get(), testDescriptor.get(), category);
+ execution = CompletableFuture.supplyAsync(() -> launchJunit(loadClasses(testBundle.get(), testDescriptor.get(), category)));
+ } catch (Exception e) {
+ execution = createReportWithFailedInitialization(e);
+ }
+ }
- execution = CompletableFuture.supplyAsync(() -> launchJunit(testClasses));
+ private static Future<TestReport> createReportWithFailedInitialization(Exception exception) {
+ TestReport.Failure failure = new TestReport.Failure("init", exception);
+ return CompletableFuture.completedFuture(
+ new TestReport.Builder()
+ .withFailures(List.of(failure))
+ .build());
}
@Override
