aboutsummaryrefslogtreecommitdiffgithub
diff options
context:
space:
mode:
authorAustin Adams <git@austinjadams.com>2018-09-03 14:34:13 -0400
committerAustin Adams <git@austinjadams.com>2018-09-03 16:46:28 -0400
commit95b12b30565ae2f2e913c55da842acaaae44bde7 (patch)
treee10ebe4739a5d500e3a57a7b19eaf25336e70c4d
parent2abe796c128f1308201e1e6e41c7b854fcd1fffa (diff)
downloadcircuitsim-grader-template-95b12b30565ae2f2e913c55da842acaaae44bde7.tar.gz
circuitsim-grader-template-95b12b30565ae2f2e913c55da842acaaae44bde7.tar.xz
In student output, show only 8 tests failures at once
Otherwise, the output is unmanageably large. Students should work through the output failure by failure — they don't need to see every single failure at once.
-rw-r--r--src/main/java/edu/gatech/cs2110/circuitsim/launcher/TestClassResult.java12
-rw-r--r--src/main/java/edu/gatech/cs2110/circuitsim/launcher/TesterLauncher.java16
2 files changed, 24 insertions, 4 deletions
diff --git a/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TestClassResult.java b/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TestClassResult.java
index d822629..c3a5c60 100644
--- a/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TestClassResult.java
+++ b/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TestClassResult.java
@@ -1,5 +1,7 @@
package edu.gatech.cs2110.circuitsim.launcher;
+import static org.junit.platform.engine.TestExecutionResult.Status.SUCCESSFUL;
+
import java.util.Collection;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -13,6 +15,7 @@ public class TestClassResult implements Comparable<TestClassResult> {
private ClassSource source;
private TestExecutionResult result;
private SortedSet<TestMethodResult> methodResults;
+ private int numFailed;
public TestClassResult(TestIdentifier id,
ClassSource source,
@@ -21,6 +24,7 @@ public class TestClassResult implements Comparable<TestClassResult> {
this.source = source;
this.result = result;
this.methodResults = new TreeSet<>();
+ this.numFailed = 0;
}
public TestIdentifier getId() { return id; }
@@ -34,6 +38,14 @@ public class TestClassResult implements Comparable<TestClassResult> {
}
public boolean addMethodResult(TestMethodResult methodResult) {
+ if (methodResult.getResult().getStatus() != SUCCESSFUL) {
+ numFailed++;
+ }
+
return methodResults.add(methodResult);
}
+
+ public int getNumFailed() {
+ return numFailed;
+ }
}
diff --git a/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TesterLauncher.java b/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TesterLauncher.java
index 97d38ed..7515c4e 100644
--- a/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TesterLauncher.java
+++ b/src/main/java/edu/gatech/cs2110/circuitsim/launcher/TesterLauncher.java
@@ -17,6 +17,7 @@ import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
public class TesterLauncher {
private static final String TEST_PACKAGE = "edu.gatech.cs2110.circuitsim.tests";
+ private static final int MAX_FAILURES = 8;
private String pkg;
private SortedSet<TestClassResult> results;
private PrintStream out, err;
@@ -99,6 +100,8 @@ public class TesterLauncher {
continue;
}
+ int numFailedPrinted = 0;
+
for (TestMethodResult methodResult : classResult.getMethodResults()) {
if (methodResult.getResult().getStatus() != SUCCESSFUL) {
if (!printedSuite) {
@@ -107,6 +110,13 @@ public class TesterLauncher {
}
out.printf("\t[FAIL] %s: %s%n", methodResult.getId().getDisplayName(),
methodResult.getResult().getThrowable().get().getMessage());
+
+ if (++numFailedPrinted == MAX_FAILURES &&
+ classResult.getNumFailed() > numFailedPrinted) {
+ out.printf("\t[%d more failures omitted]%n",
+ classResult.getNumFailed() - numFailedPrinted);
+ break;
+ }
}
}
}
@@ -125,10 +135,8 @@ public class TesterLauncher {
return false;
}
- for (TestMethodResult methodResult : classResult.getMethodResults()) {
- if (methodResult.getResult().getStatus() != SUCCESSFUL) {
- return false;
- }
+ if (classResult.getNumFailed() > 0) {
+ return false;
}
}