diff options
| author | J08nY | 2018-01-09 13:46:29 +0100 |
|---|---|---|
| committer | J08nY | 2018-01-09 13:46:29 +0100 |
| commit | 94e441b522069d3fed4b88a4823b91c1593bac68 (patch) | |
| tree | 6b8ebc96c50b7a16acdc71c74a34daa7669187a9 /src/cz/crcs/ectester/common/test/TestSuite.java | |
| parent | d19d8ad062a3c0053789eae5f7c9662399f781e0 (diff) | |
| download | ECTester-94e441b522069d3fed4b88a4823b91c1593bac68.tar.gz ECTester-94e441b522069d3fed4b88a4823b91c1593bac68.tar.zst ECTester-94e441b522069d3fed4b88a4823b91c1593bac68.zip | |
Simplify test suites.
Diffstat (limited to 'src/cz/crcs/ectester/common/test/TestSuite.java')
| -rw-r--r-- | src/cz/crcs/ectester/common/test/TestSuite.java | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/cz/crcs/ectester/common/test/TestSuite.java b/src/cz/crcs/ectester/common/test/TestSuite.java index 1a7c914..f4f30ee 100644 --- a/src/cz/crcs/ectester/common/test/TestSuite.java +++ b/src/cz/crcs/ectester/common/test/TestSuite.java @@ -1,5 +1,6 @@ package cz.crcs.ectester.common.test; +import cz.crcs.ectester.common.output.TestWriter; import cz.crcs.ectester.data.EC_Store; import java.util.Collections; @@ -13,27 +14,37 @@ import java.util.stream.Collectors; public abstract class TestSuite { protected String name; protected String description; - protected List<Runnable> run = new LinkedList<>(); - protected EC_Store dataStore; + protected TestWriter writer; - public TestSuite(EC_Store dataStore, String name, String description) { - this.dataStore = dataStore; + public TestSuite(TestWriter writer, String name, String description) { + this.writer = writer; this.name = name; this.description = description; } - public List<Runnable> getRunnables() { - return Collections.unmodifiableList(run); + public void run() throws TestException { + writer.begin(this); + try { + runTests(); + } catch (Exception e) { + throw new TestException(e); + } + writer.end(); } - @SuppressWarnings("unchecked") - public List<Test> getTests() { - return Collections.unmodifiableList((List<Test>)(List<?>) run - .stream() - .filter(runnable -> (runnable instanceof Test)) - .collect(Collectors.toList())); + protected Test runTest(Test t) throws TestException { + t.run(); + return t; } + protected Test doTest(Test t) throws TestException { + t.run(); + writer.outputTest(t); + return t; + } + + protected abstract void runTests() throws Exception; + public String getName() { return name; } |
