Chaining multiple WHENs in one scope
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
To chain multiple WHENs I have to do it in such a way:
```
GIVEN("Some background") {
WHEN("Something happens") {
THEN("The result should be") {
AND_WHEN("Other things happen") {
....
```
When I want to chain multiple WHENs the code could grow, what will lead to ugliness of scenario.
I want to accomplish the same behaviour, but with such syntax:
```
GIVEN("Some background") {
WHEN("Something happens") { // When no. 1
THEN("The result should be") {
....
}
AND_WHEN("Other things happen after "the something" ") { // When no. 2
THEN("The result should be") {
...
```
I don't want the "When no. 1" and the "When no. 2" to be executed in different test runs.
Is there any workaround to accomplish this?
Contributor guide
Research direction
Start by locating the existing GIVEN, WHEN, THEN, and AND_WHEN entry points in Catch2 and reading the tests that cover chained scenarios. Compare the current nesting behavior with the proposed syntax, then define a focused test showing that both WHEN clauses run in one scenario rather than separate test runs. No specific file or test path is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100