diff options
| author | Martin Hořeňovský | 2023-05-31 15:12:23 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2023-05-31 15:12:43 +0200 |
| commit | 0631b607ee2bbc07c7c238f0b15b23ef21926960 (patch) | |
| tree | d47dbb561250e80081ae4a6b6e56a512a978e013 /docs | |
| parent | dff7513b289f823fec91010f8898b8a01f7dcd12 (diff) | |
| download | catch3-0631b607ee2bbc07c7c238f0b15b23ef21926960.tar.gz | |
Test & document SKIP in generator constructor
Closes #1593
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/generators.md | 18 | ||||
| -rw-r--r-- | docs/skipping-passing-failing.md | 6 |
2 files changed, 24 insertions, 0 deletions
diff --git a/docs/generators.md b/docs/generators.md index 37d7424a..09799752 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -221,3 +221,21 @@ For full example of implementing your own generator, look into Catch2's examples, specifically [Generators: Create your own generator](../examples/300-Gen-OwnGenerator.cpp). + +### Handling empty generators + +The generator interface assumes that a generator always has at least one +element. This is not always true, e.g. if the generator depends on an external +datafile, the file might be missing. + +There are two ways to handle this, depending on whether you want this +to be an error or not. + + * If empty generator **is** an error, throw an exception in constructor. + * If empty generator **is not** an error, use the [`SKIP`](skipping-passing-failing.md#skipping-test-cases-at-runtime) in constructor. + + + +--- + +[Home](Readme.md#top) diff --git a/docs/skipping-passing-failing.md b/docs/skipping-passing-failing.md index 4300d9d3..d866b418 100644 --- a/docs/skipping-passing-failing.md +++ b/docs/skipping-passing-failing.md @@ -84,6 +84,12 @@ exit code, same as it does if no test cases have run. This behaviour can be overridden using the [--allow-running-no-tests](command-line.md#no-tests-override) flag. +### `SKIP` inside generators + +You can also use the `SKIP` macro inside generator's constructor to handle +cases where the generator is empty, but you do not want to fail the test +case. + ## Passing and failing test cases |