Skip to content

Visual Studio Bug: Clicking on test result sometimes kills VS2019 #328

Description

@bwandersen

Hi

We are using ::testing::RegisterTest to dynamically register test cases. The cases show up in the Test Explorer and can be run from here without any issue. However, if you click on the test result, then Visual Studio gets stuck and has to be killed from the task manager. This works fine in Visual Studio 16.9, but no longer works in 16.10.

Now the strange part is that on machines with Resharper enabled, this issue goes away. Disabling Resharper makes the problem appear again. Our guess is the recent changes to the test explorer has introduced some minor discrepancy between google test adapter and the vs test explorer.

Does anyone know what the problem might be?

Here is an example that reproduces the problem:

`#include "stdafx.h"
#include <gtest/gtest.h>

#ifdef _MSC_VER
// Windows service specifics
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX 1
#include <windows.h>
#endif

#include

using namespace std::string_literals;
using ::testing::ValuesIn;
using ::testing::Values;
using ::testing::Return;
using ::testing::An;
using ::testing::_;

class klXlTestRunner : public testing::Test
{
protected:

static void SetUpTestSuite() 
{
}

static void TearDownTestSuite() 
{
}

void SetUp() override
{
}

void TearDown() override
{

}

};

class XlTest : public klXlTestRunner {
public:
explicit XlTest(int ) : data(_) {}
void TestBody() override
{
}

private:
int data_;
};

bool RegisterXlTests()
{

std::string suite("suite");
std::string name("name");

::testing::RegisterTest(suite.c_str(),
	name.c_str(),
	nullptr,
	nullptr,
	__FILE__,
	__LINE__,
	[=]() -> klXlTestRunner* { return new XlTest(0); });

return true;

}

GTEST_API_ int main(int argc, char** argv) {
printf("Running main() from %s\n", FILE);
if (RegisterXlTests())
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
return 0;
}`

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions