catchorg / catchorg/Catch2

Support for the number of test cases running inside IEventListener

Open
#2,677 3 comments 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

**Description**
I'm writing a progress bar for the tests and it would be nice to have the total number of test cases to be executed inside the IEventListener constructor or IEventListener::testRunStarting method.

**Additional context**
I was able to achieve this by copy/pasting code from the `TestGroup` constructor to the `IEventListener` implementation but this is not a nice solution.
```
auto tests = std::set{};
auto const& allTestCases = getAllTestCasesSorted(*m_config);
auto const& testSpec = m_config->testSpec();
if (!testSpec.hasFilters())
{
for (auto const& test : allTestCases)
{
if (!test.getTestCaseInfo().isHidden())
{
tests.emplace(&test);
}
}
}
else
{
auto matches = testSpec.matchesByFilter(allTestCases, *m_config);
for (auto const& match : matches)
{
tests.insert(match.tests.begin(), match.tests.end());
}
}
m_testCount = tests.size();
```

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.