diff options
| author | J08nY | 2018-02-10 19:59:41 +0100 |
|---|---|---|
| committer | J08nY | 2018-02-10 19:59:41 +0100 |
| commit | 22e4cfaf40a259be007bddc7b5cd765390de1c11 (patch) | |
| tree | 7b7429f1215ee9e47efa4b7b2eb688c88b1cc22a /src/cz/crcs/ectester/reader/test/CommandTest.java | |
| parent | ab80803c561d05407144ffb5f1c4d45d698fec0b (diff) | |
| download | ECTester-22e4cfaf40a259be007bddc7b5cd765390de1c11.tar.gz ECTester-22e4cfaf40a259be007bddc7b5cd765390de1c11.tar.zst ECTester-22e4cfaf40a259be007bddc7b5cd765390de1c11.zip | |
Handle exceptions in Tests and TestSuites grafeully.
Diffstat (limited to 'src/cz/crcs/ectester/reader/test/CommandTest.java')
| -rw-r--r-- | src/cz/crcs/ectester/reader/test/CommandTest.java | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/cz/crcs/ectester/reader/test/CommandTest.java b/src/cz/crcs/ectester/reader/test/CommandTest.java index a08d820..d57dc17 100644 --- a/src/cz/crcs/ectester/reader/test/CommandTest.java +++ b/src/cz/crcs/ectester/reader/test/CommandTest.java @@ -3,13 +3,14 @@ package cz.crcs.ectester.reader.test; import cz.crcs.ectester.common.test.Result; import cz.crcs.ectester.common.test.SimpleTest; import cz.crcs.ectester.common.test.TestCallback; -import cz.crcs.ectester.common.test.TestException; import cz.crcs.ectester.reader.command.Command; import cz.crcs.ectester.reader.response.Response; /** * A simple test that runs one Command to get and evaluate one Response * to get a Result and compare it with the expected one. + * + * @author Jan Jancar johny@neuromancer.sk */ public class CommandTest extends SimpleTest<CommandTestable> { private CommandTest(CommandTestable command, TestCallback<CommandTestable> callback) { @@ -28,8 +29,7 @@ public class CommandTest extends SimpleTest<CommandTestable> { return new CommandTest(command, new TestCallback<CommandTestable>() { @Override public Result apply(CommandTestable commandTestable) { - Response resp = commandTestable.getResponse(); - Result.Value resultValue = Result.Value.fromExpected(expected, resp.successful(), resp.error()); + Result.Value resultValue = Result.Value.fromExpected(expected, commandTestable.ok(), commandTestable.error()); return new Result(resultValue, resultValue.ok() ? ok : nok); } }); @@ -56,21 +56,11 @@ public class CommandTest extends SimpleTest<CommandTestable> { } @Override - public void run() throws TestException { - if (hasRun) - return; - - testable.run(); - result = callback.apply(testable); - hasRun = true; - } - - @Override public String getDescription() { if (hasRun) { return testable.getResponse().getDescription(); } else { - return testable.getCommand().toString(); + return testable.getCommand().getDescription(); } } } |
