-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- "Test run started/finished" messages include class name. - More useful verbosity settings with a new option to show only the (now more useful) "Test run finished" messages. - Optional summary with more details.
- Loading branch information
Showing
8 changed files
with
124 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.novocode.junit; | ||
|
||
import sbt.testing.Status; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
class RunStatistics { | ||
private final RunSettings settings; | ||
|
||
private int failedCount, ignoredCount, otherCount; | ||
private final ArrayList<String> failedNames = new ArrayList<>(); | ||
private final ArrayList<String> otherNames = new ArrayList<>(); | ||
private volatile long accumulatedTime; | ||
|
||
RunStatistics(RunSettings settings) { | ||
this.settings = settings; | ||
} | ||
|
||
void addTime(long t) { accumulatedTime += t; } | ||
|
||
synchronized void captureStats(AbstractEvent e) { | ||
Status s = e.status(); | ||
if(s == Status.Error || s == Status.Failure) { | ||
failedCount++; | ||
failedNames.add(e.fullyQualifiedName()); | ||
} | ||
else { | ||
if(s == Status.Ignored) ignoredCount++; | ||
else otherCount++; | ||
otherNames.add(e.fullyQualifiedName()); | ||
} | ||
} | ||
|
||
private String summaryLine() { | ||
return (failedCount == 0 ? "All tests passed: " : "Some tests failed: ") + | ||
failedCount+" failed, "+ignoredCount+" ignored, "+(failedCount+ignoredCount+otherCount)+" total, "+ | ||
(accumulatedTime/1000.0)+"s"; | ||
} | ||
|
||
private static String mkString(List<String> l) { | ||
StringBuilder b = new StringBuilder(); | ||
for(String s : l) { | ||
if(b.length() != 0) b.append(", "); | ||
b.append(s); | ||
} | ||
return b.toString(); | ||
} | ||
|
||
synchronized String createSummary() { | ||
switch(settings.summary) { | ||
case LIST_FAILED: | ||
return failedNames.isEmpty() ? | ||
summaryLine() : | ||
(summaryLine() + "\n- Failed tests: " + mkString(failedNames)); | ||
case ONE_LINE: | ||
return summaryLine(); | ||
default: | ||
return ""; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters