summaryrefslogtreecommitdiff
path: root/src/main/java/au/id/zancanaro/PropertyTestRunner.java
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@zancanaro.id.au>2015-05-31 23:47:38 +1000
committerCarlo Zancanaro <carlo@zancanaro.id.au>2015-05-31 23:47:38 +1000
commita4b5a5f904fe9f21697cd8fc8998c7e6e86306af (patch)
treeb5f66d8825219f05c4e1903434a121eb40e48cbe /src/main/java/au/id/zancanaro/PropertyTestRunner.java
parent199037f9c80afd885f1f536d91b40a8397cd6bf2 (diff)
Lots more updates
+ add a list generator, and some more number generators. + bugfix the assumption checking stuff: if it failed once it would pretty likely continue to fail! + write some simple actualy properties: - reverse . reverse = id - sort . sort = sort
Diffstat (limited to 'src/main/java/au/id/zancanaro/PropertyTestRunner.java')
-rw-r--r--src/main/java/au/id/zancanaro/PropertyTestRunner.java27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/main/java/au/id/zancanaro/PropertyTestRunner.java b/src/main/java/au/id/zancanaro/PropertyTestRunner.java
index b3563ff..ea36341 100644
--- a/src/main/java/au/id/zancanaro/PropertyTestRunner.java
+++ b/src/main/java/au/id/zancanaro/PropertyTestRunner.java
@@ -178,7 +178,7 @@ public class PropertyTestRunner extends BlockJUnit4ClassRunner {
runTest(tree.getValue());
assumptionsViolated = 0;
} catch (AssumptionViolatedException ex) {
- i--;
+ numTests++;
if (assumptionsViolated++ == 50) {
throw new Error("Violated 50 assumptions in a row: failing test");
}
@@ -193,19 +193,22 @@ public class PropertyTestRunner extends BlockJUnit4ClassRunner {
private ShrinkResult shrink(RoseTree<Object[]> failed, Throwable originalEx) {
ShrinkResult smallest = new ShrinkResult(failed.getValue(), originalEx);
Iterator<RoseTree<Object[]>> trees = failed.getChildren();
+ Set<List<Object>> seenArgs = new HashSet<>();
while (trees.hasNext()) {
RoseTree<Object[]> tree = trees.next();
- try {
- runTest(tree.getValue());
- } catch (AssumptionViolatedException ex) {
- // ignore, because it's not useful
- } catch (Throwable ex) {
- smallest = new ShrinkResult(tree.getValue(), ex);
- Iterator<RoseTree<Object[]>> children = tree.getChildren();
- if (children.hasNext()) {
- trees = children;
- } else {
- break;
+ if (seenArgs.add(Arrays.asList(tree.getValue()))) {
+ try {
+ runTest(tree.getValue());
+ } catch (AssumptionViolatedException ex) {
+ // ignore, because it's not useful
+ } catch (Throwable ex) {
+ smallest = new ShrinkResult(tree.getValue(), ex);
+ Iterator<RoseTree<Object[]>> children = tree.getChildren();
+ if (children.hasNext()) {
+ trees = children;
+ } else {
+ break;
+ }
}
}
}