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

plborgprograms 20 Reputation points

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();


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?

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,632 questions
Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
337 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anna Xiu-MSFT 27,816 Reputation points Microsoft Vendor

    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.



    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