Skip to content

Commit

Permalink
method for running tests without system exit
Browse files Browse the repository at this point in the history
  • Loading branch information
wipu committed Nov 17, 2024
1 parent 72089b7 commit df4e853
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> runnerArgs = new ArrayList<>();

for (String arg : args) {
Expand All @@ -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);
}
}

}

0 comments on commit df4e853

Please sign in to comment.