diff --git a/optional/iwant-plugin-junit5runner/src/main/java/org/fluentjava/iwant/plugin/junit5runner/Junit5Runner.java b/optional/iwant-plugin-junit5runner/src/main/java/org/fluentjava/iwant/plugin/junit5runner/Junit5Runner.java index 8471d794..4c065669 100644 --- a/optional/iwant-plugin-junit5runner/src/main/java/org/fluentjava/iwant/plugin/junit5runner/Junit5Runner.java +++ b/optional/iwant-plugin-junit5runner/src/main/java/org/fluentjava/iwant/plugin/junit5runner/Junit5Runner.java @@ -9,6 +9,15 @@ public class Junit5Runner { public static void main(String[] args) { + int exitCode = -1; + try { + exitCode = run(args); + } finally { + System.exit(exitCode); + } + } + + public static int run(String[] args) { List runnerArgs = new ArrayList<>(); for (String arg : args) { @@ -17,17 +26,15 @@ public static void main(String[] args) { } if (runnerArgs.isEmpty()) { System.err.println("No tests given, exiting."); - return; + return 0; } - int exitCode = 1; try (PrintWriter out = new PrintWriter(System.out); PrintWriter err = new PrintWriter(System.err)) { - exitCode = ConsoleLauncher + return ConsoleLauncher .run(out, err, runnerArgs.toArray(new String[0])) .getExitCode(); - } finally { - System.exit(exitCode); } } + }