You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Suppose I have a test case TEST_CASE("Examples", "[Class1]") and TEST_CASE("Examples", "[Class2]") in two different tests I get the error from Catch2 due to duplicate test case name. I have encountered several times now this situation where the tests are named the same (and rightfully so) but they need to be somehow disambiguated despite having different tags. So I would like to request kind of "overloading" the test case name on tags. What I usually end up with is: TEST_CASE("Example [Class1]", "[Class1]") and being DRY believer I don't like it. Hence this request. Perhaps only the detection of the duplicates could be enhanced so that rather than failing it would append the tags to the name first (as an alias?) to see if it helps (but still failing if it did not). Or include surrounding namespace? But that is probably unknowable in a macro.
The text was updated successfully, but these errors were encountered:
Surrounding namespace detection could be possible with some __FUNCTION__ trickery, but it is not something reasonable to do.
Anyway, I am considering to allow TEST_CASEs with the same name as long as they have different source location (so file+line) for v3. However, I won't be porting this change to v2... What you can do to fix this for yourself now is to add a MY_TEST_CASE like this
Obviously this is a toy definition that has some problems (tags are now required, both test name and tags have to be a string literal), but those should be fixable with some minor complications.
Description
Suppose I have a test case
TEST_CASE("Examples", "[Class1]")
andTEST_CASE("Examples", "[Class2]")
in two different tests I get the error from Catch2 due to duplicate test case name. I have encountered several times now this situation where the tests are named the same (and rightfully so) but they need to be somehow disambiguated despite having different tags. So I would like to request kind of "overloading" the test case name on tags. What I usually end up with is:TEST_CASE("Example [Class1]", "[Class1]")
and being DRY believer I don't like it. Hence this request. Perhaps only the detection of the duplicates could be enhanced so that rather than failing it would append the tags to the name first (as an alias?) to see if it helps (but still failing if it did not). Or include surrounding namespace? But that is probably unknowable in a macro.The text was updated successfully, but these errors were encountered: