简体   繁体   中英

Running google test in visual studio 2013 express

We've just switched to using google test for unit testing due to deficiencies in our previous framework.

In Visual Studio, I have a solution with multiple projects. Each project contains unit tests using google test for a specific class (or collection of linked classes) within our application. We only use VS for managing and running google tests and reference the test classes found elsewhere.

When I want to run all tests, I set startup projects to multiple, then press ctrl-f5. This pops ups 1 console window per project with the standard google test output. This is great! I have to click a key to close each of the output windows, though. It sure would be nice to integrate into "Test Explorer" within VS2013 express.

I've found this script runner: https://visualstudiogallery.msdn.microsoft.com/9dd47c21-97a6-4369-b326-c562678066f0 .

It appears to be exactly what I want, but apparently express editions don't allow extensions? (I'm new the land of visual studio.) Anyway, we're using express instead of a different version because we're commercial. My fallback solution is spending the money on a full version of VS. However, I'd much rather find a free solution so I don't have to justify purchase, then deal with licensing visual studio for every new person that joins the group.

Has anyone figured out a solution to this?

Our team also tried using "Google Test Runner" extension. The integration with VS Test Explorer was great but we did not like the fact that we could not see gmock warnings. This means that some tests can pass with warnings and you will simply let that slip by and create problems in the future. The same problem exists when trying to use XML output generated by gmock.

Since viewing output in console is a poor option, we've decided to parse the output of executable that runs the tests and display them in a browser. To this end, we've modified the project so that it directs its output to a file ( "> test_output.txt" in Debugging -> Command Arguments) and modified the main function to parse the output, insert it into a html file template, save this html file and then open it in default browser using:

ShellExecute(NULL, NULL, "test_output.html", "", "", SW_SHOW);

This also enabled us to make some customizations to the way results are displayed using javascript.

You can use this approach in you case by creating a simple project which will run last in the list of multiple startup projects, parse the output of other executables and display it in a browser. I know this solution has its drawbacks, but it is (in my opinion) better than ignoring warnings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM