mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 05:16:10 +01:00
Highlight that SECTIONs rerun the entire test case from beginning (#2749)
This commit is contained in:
parent
b606bc2802
commit
d4e9fb8aa5
@ -119,7 +119,7 @@ This is best explained through an example ([code](../examples/100-Fix-Section.cp
|
|||||||
|
|
||||||
```c++
|
```c++
|
||||||
TEST_CASE( "vectors can be sized and resized", "[vector]" ) {
|
TEST_CASE( "vectors can be sized and resized", "[vector]" ) {
|
||||||
|
// This setup will be done 4 times in total, once for each section
|
||||||
std::vector<int> v( 5 );
|
std::vector<int> v( 5 );
|
||||||
|
|
||||||
REQUIRE( v.size() == 5 );
|
REQUIRE( v.size() == 5 );
|
||||||
@ -152,11 +152,12 @@ TEST_CASE( "vectors can be sized and resized", "[vector]" ) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
For each `SECTION` the `TEST_CASE` is executed from the start. This means
|
For each `SECTION` the `TEST_CASE` is **executed from the start**. This means
|
||||||
that each section is entered with a freshly constructed vector `v`, that
|
that each section is entered with a freshly constructed vector `v`, that
|
||||||
we know has size 5 and capacity at least 5, because the two assertions
|
we know has size 5 and capacity at least 5, because the two assertions
|
||||||
are also checked before the section is entered. Each run through a test
|
are also checked before the section is entered. This behaviour may not be
|
||||||
case will execute one, and only one, leaf section.
|
ideal for tests where setup is expensive. Each run through a test case will
|
||||||
|
execute one, and only one, leaf section.
|
||||||
|
|
||||||
Section can also be nested, in which case the parent section can be
|
Section can also be nested, in which case the parent section can be
|
||||||
entered multiple times, once for each leaf section. Nested sections are
|
entered multiple times, once for each leaf section. Nested sections are
|
||||||
|
Loading…
Reference in New Issue
Block a user