diff options
| author | J08nY | 2018-03-06 21:47:46 +0100 |
|---|---|---|
| committer | J08nY | 2018-03-06 21:47:46 +0100 |
| commit | db1f7faf4608d5552293e2ea7e49a6b2a069f7ea (patch) | |
| tree | 6ef0a1807ce4c4dd301f0954be7f76f29afeb61f /src/cz/crcs/ectester/common/test/CompoundTest.java | |
| parent | 5f7fe35a1f6ca79e48443096db74a21c134b12a2 (diff) | |
| download | ECTester-db1f7faf4608d5552293e2ea7e49a6b2a069f7ea.tar.gz ECTester-db1f7faf4608d5552293e2ea7e49a6b2a069f7ea.tar.zst ECTester-db1f7faf4608d5552293e2ea7e49a6b2a069f7ea.zip | |
Diffstat (limited to 'src/cz/crcs/ectester/common/test/CompoundTest.java')
| -rw-r--r-- | src/cz/crcs/ectester/common/test/CompoundTest.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/cz/crcs/ectester/common/test/CompoundTest.java b/src/cz/crcs/ectester/common/test/CompoundTest.java index 4b1df16..d7a2d9c 100644 --- a/src/cz/crcs/ectester/common/test/CompoundTest.java +++ b/src/cz/crcs/ectester/common/test/CompoundTest.java @@ -82,6 +82,43 @@ public class CompoundTest extends Test { return result; } + public static CompoundTest greedyAllTry(Result.ExpectedValue what, Test... all) { + return new CompoundTest((tests) -> { + int run = 0; + int ok = 0; + for (Test test : tests) { + if (test.hasRun()) { + run++; + if (Result.Value.fromExpected(what, test.ok()).ok()) { + ok++; + } + } + } + if (run == tests.length) { + if (ok == run) { + return new Result(Result.Value.SUCCESS, "All sub-tests had the expected result."); + } else { + return new Result(Result.Value.FAILURE, "Some sub-tests did not have the expected result."); + } + } else { + return new Result(Result.Value.SUCCESS, "All considered sub-tests had the expected result."); + } + }, (tests) -> { + for (Test t : tests) { + t.run(); + if (!t.ok()) { + break; + } + } + }, all); + } + + public static CompoundTest greedyAllTry(Result.ExpectedValue what, String description, Test... all) { + CompoundTest result = CompoundTest.greedyAllTry(what, all); + result.setDescription(description); + return result; + } + public static CompoundTest greedyAny(Result.ExpectedValue what, Test... any) { return new CompoundTest((tests) -> { for (Test test : tests) { |
