| ... | ... | @@ -49,6 +49,11 @@ Each `SECTION` of a test case will be executed in standalone, meaning that that |
|
|
|
This allows for 2 things :
|
|
|
|
1. Factorize all the common setup & teardown required for tests.
|
|
|
|
2. Creating scenarios for your `TEST_CASE` and test each one separately.
|
|
|
|
> **About sections names**
|
|
|
|
> Tests are a place in a codebase where people go to understand how to interact with a function or an object. To help them it is advised to have explicit and verbous tests.
|
|
|
|
> This can be done in 2 ways :
|
|
|
|
> 1. with a lot of comment
|
|
|
|
> 2. a bit of context : having explicit section name to understand the scenario can help with that.
|
|
|
|
### Create assertions
|
|
|
|
You can add assertions in your tests that should fail and stop the execution (or not) if the program behaviour is not as expected. You can find every assertions available on the official Catch2 [documentation](https://github.com/catchorg/Catch2/blob/devel/docs/tutorial.md). Here are some examples:
|
|
|
|
- `REQUIRE(<true_false_statement>)`
|
| ... | ... | |