diff --git a/core/src/testFixtures/java/org/lflang/tests/LFTest.java b/core/src/testFixtures/java/org/lflang/tests/LFTest.java index e99fee4b54..1fa4184237 100644 --- a/core/src/testFixtures/java/org/lflang/tests/LFTest.java +++ b/core/src/testFixtures/java/org/lflang/tests/LFTest.java @@ -39,6 +39,12 @@ public class LFTest implements Comparable { /** String builder for collecting issues encountered during test execution. */ private final StringBuilder issues = new StringBuilder(); + /** Reference to System.out for restoring the default output. */ + private static final PrintStream out = System.out; + + /** Reference to System.err for restoring the default output. */ + private static final PrintStream err = System.err; + private long executionTimeNanoseconds; /** @@ -71,11 +77,11 @@ public void redirectOutputs() { } /** End output redirection. */ - public void restoreOutputs() { + public static void restoreOutputs() { System.out.flush(); System.err.flush(); - System.setOut(System.out); - System.setErr(System.err); + System.setOut(out); + System.setErr(err); } /** @@ -130,7 +136,7 @@ public boolean hasPassed() { return result == Result.TEST_PASS; } - /** Compile a string that contains all collected errors and return it. */ + /** Print a report of all the collected errors. */ public void reportErrors() { if (this.hasFailed()) { System.out.println( diff --git a/core/src/testFixtures/java/org/lflang/tests/TestBase.java b/core/src/testFixtures/java/org/lflang/tests/TestBase.java index ee0d72ff02..04a699068c 100644 --- a/core/src/testFixtures/java/org/lflang/tests/TestBase.java +++ b/core/src/testFixtures/java/org/lflang/tests/TestBase.java @@ -328,7 +328,7 @@ private static void checkAndReportFailures(Set tests) { var passed = tests.stream().filter(LFTest::hasPassed).toList(); var s = new StringBuffer(); s.append(THIN_LINE); - s.append("Passing: ").append(passed.size()).append("/").append(tests.size()).append("%n"); + s.append(String.format("Passing: %d/%d%n", passed.size(), tests.size())); s.append(THIN_LINE); passed.forEach( test ->