When are test cases run without sections?
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
I am a bit unclear on when the code in a TEST_CASE is run when there are nested SECTIONs. I can't find anything about the details in the documentation so I am not sure what the intended action is here and whether there is a bug or not.
Here is some example code:
``` c++
TEST_CASE("run once with section") {
printf("a0\n");
SECTION("foo") {
printf("a1\n");
}
printf("a2\n");
}
TEST_CASE("run twice with and without section") {
int error = 0;
printf("b0\n");
try {
printf("b1\n");
SECTION("bar") {
printf("b2\n");
throw 1;
}
printf("b3\n");
} catch (int e) {
printf("b4\n");
error = e;
}
printf("b5\n");
REQUIRE(error > 0);
}
```
This prints out:
```
a0
a1
a2
b0
b1
b2
b4
b5
b0
b1
b3
b5
```
indicating that the first example was only run once, but the second was run twice, once without and once with the `SECTION("bar")` code.
See also #191.
Contributor guide
Research direction
Start by reproducing the provided TEST_CASE and SECTION examples, then read the documentation and behavior related to TEST_CASE execution and nested SECTIONs. Compare the output for both examples and review related issue #191. Done means documenting when code outside a SECTION runs and why the second test executes twice.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation, testing-qa
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100