catchorg / catchorg/Catch2

Running specific "WHEN" or "THEN" section fails

Open
#2,170 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

**Describe the bug**
When trying to run only a specific section, e.g. "S1"

`./test-message-processing "TestCase" -c "S1"`

catch2 cannot find the section, resulting in just running through "TestCase" without any sections.

```
TestCase
===============================================================================
test cases: 1 | 1 passed
assertions: - none -
```
This works however when not using the WHEN syntax, but a normal SECTION instead.
I tried to experiment with things like

`./test-message-processing "TestCase" -c "When: S1"`

but that did not work either.

**Expected behavior**
Only the given section is run.

**Reproduction steps**
```cpp
TEST_CASE("TestCase") {
std::cout << "TestCase" << std::endl;

WHEN("S1") {
std::cout << "S1" << std::endl;

THEN("S1.1") {
std::cout << "S1.1" << std::endl;
}

THEN("S1.2") {
std::cout << "S1.2" << std::endl;
}
}

WHEN("S2") {
std::cout << "S2" << std::endl;
}
}
```

**Platform information:**
- OS: **Lubuntu 20.04**
- Compiler+version: **gcc 9.3.0**
- Catch version: **v2.6.0**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.