Closed L4ZZA closed 4 years ago
That won't work ;-)
Traits support is a Visual Studio specific feature. The trait macros you are using encode the traits information into the gtest executable in a certain way; however, gtest doesn't know anything about this, and thus the traits are completely useless when running gtest executables from the console.
However, you can run your executables with the help of VsTest.Console.exe
and Google Test Adapter, and can then filter the tests to be run by means of the traits. For a working example open and build the GTA solution, place a breakpoint at this line, and run test SampleTests_Settings_Type_EQ_Small
- you will see how to invoke VsTestConsole.exe
for the sake of filtering with traits.
Let me know whether this helps...
The solution fails to build and I don't want to investigate that too. My problem is that we have thousands of tests scattered in different test assemblies some of which we've found out are not actual unit tests, so I wanted to tag all unit tests as such and only run those using the filter for the traits. Now, knowing that traits are only an option using vstest.console and that vstest.console is not working as expected, I don't know how can I achieve this without having to manually move each test to a different project (i.e unitTest_cpp.exe -> otherTest_cpp.exe)
See Wiki for build instructions - shouldn't be too hard. However, here's the resulting command line on my machine:
VsTestConsole.exe /Logger:Trx /TestAdapterPath:C:\Users\chris\git\GoogleTestAdapter\out\binaries\GoogleTestAdapter\Debug\Packaging.GTA "..\..\..\..\..\out\binaries\SampleTests\Debug\Tests_gta.exe" /TestCaseFilter:"Type=Small"
Packaging.GTA
folder is the folder where GTA is located, Tests_gta.exe
is the test executable compiled from the code at SampleTests/Tests
.
Not sure what you mean by "vstest.console is not working as expected"...
May traits by regexes be an option?
I'm closing this due to inactivity. Feel free to add more questions.
I can't seem to only run tests, categorised as UnitTest by a given trait, by specifying the --gtest_filter=UnitTest
Code
Result