googletest icon indicating copy to clipboard operation
googletest copied to clipboard

[Bug]: Can't use a fixture from another namespace

Open maliberty opened this issue 2 months ago • 3 comments

Describe the issue

Using a fixture from another namespace leads to compiler errors.

Steps to reproduce the problem

Compiling:

#include "gtest/gtest.h"

namespace X {
class Fixture
{
};
};  // namespace X

TEST_F(X::Fixture, test)
{
}

gives

foo.cc:9:1: error: qualified name does not name a class before ‘:’ token
    9 | TEST_F(X::Fixture, test)
      | ^~~~~~
```


I believe this results from 

```
#define GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
  test_suite_name##_##test_name##_Test
```

generating `class X::Fixture_test_Test : public X::Fixture`

### What version of GoogleTest are you using?

1.13.0

### What operating system and version are you using?

Ubuntu 24.02

### What compiler and version are you using?

g++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0


### What build system are you using?

n/a

### Additional context

_No response_

maliberty avatar Oct 06 '25 20:10 maliberty