hyperskill / hs-test

A framework that simplifies testing educational projects for Hyperskill. It is built on top of JUnit.
30 stars 10 forks source link

Allow throwing some error as the way to fail the test #52

Closed aaaaaa2493 closed 4 years ago

aaaaaa2493 commented 5 years ago

Now the test is assumed to be failed only if methods .addInput, check return CheckResult object. This can be hard if checking goes deep into several methods (for example, parsing output) and encounteres that something is wrong. Since return statement can be made only in .addInput, check you actually need to write something like:

... deep into methods
       throw new Exception(feedback);
...

... check method
List<Grid> grids;
try {
     grids = Grid.parse(out);
} catch (Exception ex) {
     return CheckResult.FALSE(ex.getMessage());
}
...

but with this issue implemented it can be something like this (less boilerplate):

... deep into methods
       throw new FailTestError(feedback);
...

... check method
List<Grid> grids = Grid.parse(out);
...
aaaaaa2493 commented 4 years ago

Fixed in https://github.com/hyperskill/hs-test/commit/917be4bd8b9a4b165af8d190100c1fb8c7310478 and https://github.com/hyperskill/hs-test/commit/f9e4d63d129272e4ac5bb978f171147261f0332c