So the interface to support multiple tests from a single file has to be easy...
All you need do is print the right stuff to stdout and stderr and return the right value and you're done.
In the single test case all that mattered was the return value, everything else was just informational in the case of failure.
So what should the output look like to make multiple tests work... well here's a sample.
STDOUT
test_00_dummy_pass: OK test_01_dummy_fail: FAILED 1/2
STDERR
<@saru start test_00_dummy_pass @> Some info about the dummy_pass test <@saru end test_00_dummy_pass @> <@saru start test_01_dummy_fail @> This test fails And so this message will appear in the test output <@saru end test_01_dummy_fail @>
Whipping up a python script that prints these outputs and running it through
saru-run-test suite .gives the following results
test.py::test_00_dummy_pass : OK test.py::test_01_dummy_fail : FAILED??? ==MESSAGE== ==STDERR== This test fails And so this message will appear in the test output 1 / 2
Admitadly the output is not that pretty, and the mechanism is not prefectly robust.
But it has done everything I need from running multiple tests from a single file.
Of course you'd probably want to write a helper library to get that outputting correct.
And to help you use "good testing practices" like fixtures.
Some of these helper libraries already exist. The C++ one is already part of saru, as a pure header. There is a python helper library that will be added shortly, and a PHP library that is in development.
I might look at how to use the C++ library in a future post.
No comments:
Post a Comment