Skip to content

Commit

Permalink
The tester should not say success if a container is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
forax committed Jul 1, 2018
1 parent b7c5b58 commit a8cc123
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.github.forax.pro.plugin.tester;

import static org.junit.platform.engine.discovery.DiscoverySelectors.selectModule;
import static org.junit.platform.engine.discovery.DiscoverySelectors.*;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.function.IntSupplier;

import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
Expand Down Expand Up @@ -37,6 +36,7 @@ private static int launchJUnitPlatform(TestConf testConf) {

var builder = LauncherDiscoveryRequestBuilder.request();
builder.selectors(selectModule(moduleName));
//builder.selectors(selectPackage(moduleName));
builder.configurationParameter("junit.jupiter.execution.parallel.enabled", Boolean.toString(parallel));

var launcher = LauncherFactory.create();
Expand All @@ -46,16 +46,20 @@ private static int launchJUnitPlatform(TestConf testConf) {
launcher.execute(launcherDiscoveryRequest, summaryGeneratingListener);
var duration = System.currentTimeMillis() - startTimeMillis;
var summary = summaryGeneratingListener.getSummary();
int failures = (int) summary.getTestsFailedCount();
if (failures == 0) {

// DEBUG
//summary.printTo(new PrintWriter(System.out));

var success = summary.getTestsFailedCount() == 0 && summary.getTestsAbortedCount() == 0 &&
summary.getContainersFailedCount() == 0 && summary.getContainersAbortedCount() == 0;
if (success) {
var succeeded = summary.getTestsSucceededCount();
System.out.printf("[tester] Successfully tested %s: %d tests in %d ms%n", moduleNameAndVersion, succeeded, duration);
} else {
var stringWriter = new StringWriter();
summary.printTo(new PrintWriter(stringWriter));
summary.printFailuresTo(new PrintWriter(stringWriter));
System.out.println(stringWriter);
var writer = new PrintWriter(System.err);
summary.printTo(writer);
summary.printFailuresTo(writer);
}
return failures;
return success? 0: 1;
}
}

0 comments on commit a8cc123

Please sign in to comment.