summaryrefslogtreecommitdiff
path: root/src/main/java/au/id/zancanaro/javacheck/junit
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@zancanaro.id.au>2015-06-11 00:27:06 +1000
committerCarlo Zancanaro <carlo@zancanaro.id.au>2015-06-11 00:27:06 +1000
commitb2055f2a1dd2117cdd05ab6596c38c82d3d05240 (patch)
tree934b34851897b7e781f09da8a8749db473b9f4cd /src/main/java/au/id/zancanaro/javacheck/junit
parent60bc9218d0872e40a6857706d51955ee3d058717 (diff)
Report command lists more nicely (line breaks between commands); report number of nodes visited during shrinking; other small fixes
Diffstat (limited to 'src/main/java/au/id/zancanaro/javacheck/junit')
-rw-r--r--src/main/java/au/id/zancanaro/javacheck/junit/Properties.java12
-rw-r--r--src/main/java/au/id/zancanaro/javacheck/junit/PropertyError.java8
2 files changed, 12 insertions, 8 deletions
diff --git a/src/main/java/au/id/zancanaro/javacheck/junit/Properties.java b/src/main/java/au/id/zancanaro/javacheck/junit/Properties.java
index c428edc..175cd6c 100644
--- a/src/main/java/au/id/zancanaro/javacheck/junit/Properties.java
+++ b/src/main/java/au/id/zancanaro/javacheck/junit/Properties.java
@@ -116,26 +116,30 @@ public class Properties extends BlockJUnit4ClassRunner {
private ShrinkResult shrink(ShrinkTree<List<Object>> failed, Throwable originalEx) {
// this array is a mutable container so the shutdown handler can see the new version
ShrinkResult[] smallest = new ShrinkResult[]{
- new ShrinkResult(failed.getValue(), originalEx)};
+ new ShrinkResult(failed.getValue(), originalEx, 0, 0)};
Thread shutdownHandler = makeShutdownHandler(smallest, originalEx);
Runtime.getRuntime().addShutdownHook(shutdownHandler);
+ int depth = 0;
+ int visited = 0;
Set<List<Object>> seenArgs = new HashSet<>();
Iterator<ShrinkTree<List<Object>>> trees = failed.getChildren().iterator();
while (trees.hasNext()) {
ShrinkTree<List<Object>> tree = trees.next();
List<Object> value = tree.getValue();
- boolean haveSeen = seenArgs.add(Arrays.asList(value));
- if (haveSeen) {
+ boolean notSeen = seenArgs.add(Arrays.asList(value));
+ if (notSeen) {
+ visited++;
try {
runTest(value.toArray());
} catch (AssumptionViolatedException ex) {
// ignore, because it's not useful
} catch (Throwable ex) {
- smallest[0] = new ShrinkResult(tree.getValue(), ex);
+ smallest[0] = new ShrinkResult(tree.getValue(), ex, depth, visited);
Iterator<ShrinkTree<List<Object>>> children = tree.getChildren().iterator();
if (children.hasNext()) {
+ depth++;
trees = children;
} else {
break;
diff --git a/src/main/java/au/id/zancanaro/javacheck/junit/PropertyError.java b/src/main/java/au/id/zancanaro/javacheck/junit/PropertyError.java
index 5f89ca8..4f02a56 100644
--- a/src/main/java/au/id/zancanaro/javacheck/junit/PropertyError.java
+++ b/src/main/java/au/id/zancanaro/javacheck/junit/PropertyError.java
@@ -9,12 +9,12 @@ import java.util.List;
public class PropertyError extends AssertionError {
public PropertyError(String methodName, long seed, ShrinkResult shrunk) {
super(shrunk.thrown.getMessage() == null ?
- String.format("%s(%s)%n\tSeed: %s",
+ String.format("%s(%s)%n\tSeed: %s%n\tVisited: %s; Depth: %s",
methodName, joinArgs(shrunk.args),
- seed):
- String.format("%s(%s)%n\tSeed: %s%n%s",
+ seed, shrunk.visited, shrunk.depth):
+ String.format("%s(%s)%n\tSeed: %s%n\tVisited: %s; Depth: %s%n%s",
methodName, joinArgs(shrunk.args),
- seed,
+ seed, shrunk.visited, shrunk.depth,
shrunk.thrown.getMessage()));
initCause(shrunk.thrown);
}