mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
@@ -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)
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user