'Is there a Catch2 variable that provides the name of the current test?
I'm using Catch2 for unit tests and I would like to know the name of a C++ or environment variable that reveals the name of the current test that is executing.
Is there a way to do this, or is it bad form to have the test debugging code print the name of the test in which it is running? Ideally I'd like to print it using the CAPTURE Macro.
The reason that I want to do this is that I have many Catch2 tests and some of them generate voluminous output. Some generate the exact same output. Some generate output that should be the same but sometimes isn't. The output is not generated in the body of the unit test, but instead in a function called. So I would like to be able to label the output according to the macro that generated it.
I suppose that one way to do this would be to use a scaffold that stores the name into a global variable, or an environment variable.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
