eugeneie / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Avoid test class name collisions. #254

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When I define two test classes with the same name, but place them in
separate namespaces, gtest spits out an error that the two test suites
collided: 

namespace A {
class MyTest : public testing::Test {}
TEST_F( MyTest, TestBlah ) {}
}

namespace B {
class MyTest : public testing::Test {}
TEST_F( MyTest, TestBarf ) {}
}

I took a brief look at the implementation of TEST_F to see why. It looks
like down in the GTEST_TEST() (which is called by TEST_F()), we are
registering the auto-generated test class using the fixture name only.
Would it be possible to augment this with the namespace as well to avoid
collisions? Something like:

TEST_F( A, MyTest, TestBlah ) {}
TEST_F( B, MyTest, TestBarf ) {}

Original issue reported on code.google.com by JCYo...@gmail.com on 12 Feb 2010 at 10:58

GoogleCodeExporter commented 9 years ago
We'd like to keep the model simple.  Instead of

  TEST_F(A, MyTest, TestBlah)

please write something like

  TEST_F(A_MyTest, TestBlah)

Original comment by w...@google.com on 12 Feb 2010 at 11:08