Cannot Extract Method from Macro, e.g. TEST
Giving the following example
```cpp
TEST(ImplementationTests, EraseInLoop)
{
std::vector<int> numbers = {1, 2, 3, 4, 5};
const int deleteNumber = 2;
//select from here ...
for(auto it = numbers.begin(); it != numbers.end(); )
{
if(*it == deleteNumber) it = numbers.erase(it);
else ++it;
}
//till here
}
```
Calling the Extract Method from the Refactor menu is not possible. ReSharper does not allow any refactoring here. If it would be wrapped in a simple function instead of a TEST macro it is working fine.
Please sign in to leave a comment.
Hello,
I've created https://youtrack.jetbrains.com/issue/RSCPP-28095 to track this. The problem with C++ tests is that the test code is actually a function inside a class (in case of Google Test), both of which come from the macro expansion. "Extract method" in C++ can only insert the new method immediately before the function from which the code is extracted, so it gets disabled inside test code.
Thanks for the report!