Test cases not discovered/How to show output of Discover Tests in Test Explorer

plborgprograms 20 Reputation points
2023-05-25T02:23:19.3833333+00:00

I'm writing unit tests for a c++ project using Visual Studio, Test Explorer, and google test. I have two classes to test 'Strategy' and 'StockThread'. If I declare my class of type Strategy, none of the test cases are discovered by Test Explorer and I can't run any of them. Moreover, I don't see any output to help debug the problem.

If instead, I declare a class of type "StockThread", the tests are discovered as intended. The project being tested compiles and runs on its own, and the "Strategy" class is the first class declared.

The Test Explorer shows the problematic behavior.

test cases not found

If I comment out the line and change it to declare a StockThread, it's able to run.

test cases found

Here is the code that produces the issue


TEST(TestStrategy, TestStrategyDeclaration)
{
	//This other class, if declared instead, runs properly
	//StockThread st;

	//**declaring objects of type Strategy causes all the test cases to disappear
	Strategy* strat = new Strategy();

	EXPECT_TRUE(true);
}

When I compile with Strategy commented or uncommented, I get the following:

Build started... 1>------ Build started: Project: GoogleUnitTesting, Configuration: Release Win32 ------ 1>unittest.cpp 1>C:\Eclipse-workspace\TWS API\source\CppClient\client\platformspecific.h(16,1): warning C4005: 'assert': macro redefinition 1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\assert.h(26): message : see previous definition of 'assert' 1>GoogleUnitTesting.vcxproj -> C:\Eclipse-workspace\TWS API\samples\Cpp\AcceleratedInvesting\Release\GoogleUnitTesting.exe 1>Done building project "GoogleUnitTesting.vcxproj". ========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

Is there a way to see the output of the tool running discover tests so I can see why it doesn't find the tests?

Developer technologies Visual Studio Testing
Developer technologies C++
0 comments No comments
{count} votes

Accepted answer
  1. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2023-05-25T09:35:12.42+00:00

    Hi @plborgprograms

    Welcome to Microsoft Q&A! 

    Please check the build configuration and architecture. Then, try to Build > Rebuild Solution

    If it persists, you can go to View > Output > Show output from: Tests and check the tests details.

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

     


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.