Skip to content
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

[junit-platform] Handle null summary if no tests found #5408

Merged
merged 1 commit into from Oct 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -49,6 +49,7 @@
import org.junit.platform.launcher.core.LauncherFactory;
import org.junit.platform.launcher.listeners.LoggingListener;
import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
import org.junit.platform.launcher.listeners.TestExecutionSummary;
import org.osgi.annotation.bundle.Header;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
Expand Down Expand Up @@ -432,6 +433,7 @@ long test(LauncherDiscoveryRequest testRequest) {
ServiceTracker<TestExecutionListener, TestExecutionListener> track = new ServiceTracker<>(context,
TestExecutionListener.class, null);
track.open();
final TestExecutionSummary execSummary;
try {
TestExecutionListener[] listenerArray = Stream
.concat(listeners.stream(), Arrays.stream(track.getServices(new TestExecutionListener[0])))
Expand All @@ -440,17 +442,20 @@ long test(LauncherDiscoveryRequest testRequest) {
} catch (Throwable t) {
trace("%s", t);
} finally {
execSummary = summary.getSummary();
track.close();
trace(null, () -> {
CharArrayWriter sw = new CharArrayWriter();
summary.getSummary()
.printTo(new PrintWriter(sw));
return sw.toString();
});
if (execSummary != null) {
trace(null, () -> {
CharArrayWriter sw = new CharArrayWriter();
execSummary.printTo(new PrintWriter(sw));
return sw.toString();
});
} else {
trace("No summary available");
}
}

return summary.getSummary()
.getTotalFailureCount();
return (execSummary != null) ? execSummary.getTotalFailureCount() : -1;
} catch (Exception e) {
e.printStackTrace();
}
Expand Down