Closed jtl313 closed 2 years ago
Thanks for the great bug report! However, I don't think that GTA is to blame here since it merely runs your executable with .NET's Process framework, but is not involved at all with collecting code coverage information - this is done by vstest.console.exe
. I fear that I can't help here.
I would maybe try a different gtest version then the one provided by MS (e.g. add the gtest code to your solution, build it yourself, and link that version), or to talk to the MS Test guys providing vstest.console.exe
. One more thing you could try is to use Test Adapter for Google Test (MS' clone of GTA) instead of GTA, but I expect the same behavior from that one.
Let me know if you could solve the problem - might be something for the trouble shooting section of the GTA docs!
I will close this issue since it probably indeed is a VsTest problem, but in case relevant information is added to https://github.com/microsoft/codecoverage/issues/32 maybe you could leave a short notice here - thanks!
We suddenly got a problem running our unit tests. After a bit of fiddling with the code I was able to extract a minimal example that display the same kind of problem. It seems that having a global thread_local smart pointer anywhere in the test code makes GTA fail to discover tests if code coverage is also collected. This is the problem code:
If running this code through the following
vstest.console.exe mytest.exe /TestAdapterPath:<gta path> /Collect:"Code Coverage"
test discovery fails with a message similar to:If I either remove /Collect:"Code Coverage" from the command line, or if I comment out the global_smart_pointer, everything runs just fine.
I have tested with GTA 0.17.1 and 0.18.0 and vstest.console.exe version 16.9.4 and 17.0.0 with the same result. The code is compiled with VS2019
Running mytest.exe --gtest_list_tests from the command line works fine in all situations.
Update: Interestingly the problem seem to only occur when linking statically with gtest. I used "Microsoft.googletest.v140.windesktop.msvcstl.static.rt-static" version="1.8.1.5". So the problem may be with gtest as well. Test code: https://github.com/jtl313/gta-test