A great tool! Will save you a lot of hassle with changing the --gtest_filter in the debug options. For VS2015 either unpack the vsix and update the manifest or download a VS 2015 compatible from the project github repo.
It works, but for comprehensive support of Google Test in Visual Studio you might want to consider ReSharper C++. Check out this screencast for a detailed walkthrough: https://www.youtube.com/watch?v=16FI1-d2P4E
Found this nice adapter, but can't use it because the regular expression used to match tests is overly strict. I don't want to rename all my 100s of tests. Please make the regular expression configurable, or allow the word 'Test' to either appear at the beginning or ending of the executable name.
Works great. To get started you need to download and install Google Test from google's website. Instructions are here: https://www.youtube.com/watch?v=n1OL800IcXI Then use these instructions to have the results of google test show up in "Test Explorer" inside of the VS IDE. https://github.com/markusl/GoogleTestRunner
I have Visual Studio 2013 running on Windows 10. I have .NET Framework 4.6 installed. When I try to install the extension, it fails. From the logs I see that the reason is that the only supported version is .NET 4.5. I cannot install bot 4.5 and 4.6 at the same time, as .NET 4.5 installer refuses it.
As I've attempted to fix the issue by cloning the repo and fixing the code, I had to install VS 2015 and Visual F#. Surprisingly, once I've finished the installation, I was able to install the plugin without making any changes. Not sure what it was, but probably so components installed with VS 2015 were missing.
I have successfully downloaded and used the extension on Visual Studio 2015. It works great and all gtests are discovered in Visual Studio Test Explorer.
However, the extension is producing empty folders under the default TestResult folder. Shouldn't the extension produce something?
The same thing is reproduced when using the vstest.console.exe command to call the unit test. As a workaround, to produce TestResults one need to pass the /Logger option (at least it is working with /Logger:trx option).
e.g. vstest.console.exe Calculator.Tests.exe /EnableCodeCoverage /UseVsixExtensions:true /Logger:trx
If you do not want to wait for a new build, you can also get it working with Visual Studio 2015 by editing the extension manifest manually:
- Download the ".vsix" file (link above)
- Unpack the file (it's just a ZIP)
- Edit the file 'extension.vsixmanifest' and
- Replace the <InstallationTarget> with the following: <InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[14.0,]" />
- Create a ZIP archive including all files and change the file extension back to ".vsix"
- Double-click to install
This way, I got it working in Visual Studio 2015.
I installed the extension in VS 2015 using Daniel Joos's suggestion. However, Test Explorer isn't discovering any tests from my test project. This used to work fine in VS 2013.
As far as I can tell, my executable isn't even being run to discover the tests. I can run the tests themselves just fine by executing the project.
Anyone have any ideas?
Change Request: When the GoogleTest Runner is looking for symbols in a test executable, it outputs messages like:
Loading symbols from <my>.exe
From <my>.exe, found <n> symbols in <n> ms
These messages are set as warnings, which, also makes them appear as warnings in automated build systems like TFS. Would it be possible to reduce their level from warning to debug or informational? This would remove the "warnings" , which makes it easier to make sure that new warnings are not being added due to less clutter.
I'm suddenly getting this error, is that due to a bug in the extension? The error seem to indicate problems parsing the XML result file:
------ Run test started ------
Found 33 tests, resolving symbols
Loading symbols from C:\Users\Thomas\SourceTree\SUbD\Test\SUbD_UnitTest.exe
From C:\Users\Thomas\SourceTree\SUbD\Test\SUbD_UnitTest.exe, found 33 symbols in 71 ms
In C:\Users\Thomas\SourceTree\SUbD\Test, running: C:\Users\Thomas\SourceTree\SUbD\Test\SUbD_UnitTest.exe --gtest_output="xml:C:\Users\Thomas\AppData\Local\Temp\tmp9313.tmp"
Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
at GoogleTestRunner.ResultParser.getResults(IMessageLogger logger, String outputPath, FSharpList`1 testCases)
at GoogleTestRunner.GoogleTestExecutor.runOnce(IFrameworkHandle framework, IRunContext runContext, FSharpList`1 allCases, FSharpList`1 cases, String executable, Boolean runAll)
at GoogleTestRunner.GoogleTestExecutor.runTests(FSharpList`1 allCases, IEnumerable`1 cases, IRunContext runContext, IFrameworkHandle framework, Boolean runAll)
No test is available in C:\Users\Thomas\SourceTree\SUbD\Test\SUbD_UnitTest.exe. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
========== Run test finished: 0 run (0:00:08.1626713) ==========
I had the exact same problem and it was caused by the fact that the character set of my test project was set to UNICODE. Changing it to multibyte character set solved the problem (project->properties->general->character set).
To get the Google test runner to work I also had to change the signature of the auto generated main method to int _tmain(int argc, char *argv).
As ThomThom noted, if something causes the gtest executable to exit during test execution the output xml file is empty. I experienced the issue with a regular C++ assert (from assert.h). It would be nice if the test runner was expanded to create a xml file with an appropriate error message, e.g. "Test exited before writing xml output", or something like that.
I have a solution compiled under x64. Parameter tests (TEST_P) are executed, but the Source: entry contains either "TestBody" (when << is defined for the parameter struc) or nothing (when not) and the navigation to the source code does not work. For TEST_F everything works as expected.
Any idea what could be the reason? Changing the Default Processor Architecture under Test => Test Settings did not help.
I have this adapter running and works well. But I want to have this incorporated into my build process. Not just the unit test execution but the Code Coverage analysis as well.
There are plenty of places in MSDN documentation that point to the ability to customize the build service to both run your unit tests and to turn on code coverage analysis during that process.
BUT I cannot find how I might configure my NON-Team version of Visual Studio 2013 (Premium) to run and analyze my GTEST unit tests. I have them running in a post-build step run now, but I want them to run and analyze for code coverage. Of course, I can run them in the Test Explorer, but I want them incorporated into the build process.
Just FYI here is the stuff I have read already.
the "Analyzing code coverage in the build service" section in https://msdn.microsoft.com/en-us/library/dd537628.aspx
This separate help https://msdn.microsoft.com/en-us/library/jj159524.aspx
The https://msdn.microsoft.com/en-us/library/jj155796.aspx for customizing command line.
And various places that help explain customize run settings in a build definition
I figured out how to do the code coverage via command line directly (once the GoogleTestRunner plugin is installed). This allows you to put it in the build process as well.
You must use the vstest.console.exe command, with the extension and code coverage switches. Here is an example of how that works--
vstest.console.exe YourTest.exe /UseVsixExtensions:true /EnableCodeCoverage /Settings:test.runsettings /inIsolation
Using that format, everything works properly.
NOTE: you must have Visual Studio Premium or Ultimate for this to work (I am using this *without* TFS)