Can vstest.console filter tests by all matched traits?
Asked Answered
T

2

6

As documented on this MSDN article, vstest.consolecan filter tests to run by traits. For example, a sample vstest.console command might look as follows:

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "C:\mytest.dll" /TestCaseFilter:"TestCategory=traitA|TestCategory=traitB|traitN" /logger:trx

Actually, the whole article says that multiple traits will be provided using the following syntax:

<Expression> is of the format <property>=<value>[|<Expression>].

My issue is when you provide more than a trait, tests are filtered using a logical or and official documentation says nothing about how to filter tests that match all given traits.

Teflon answered 18/12, 2015 at 10:7 Comment(4)
if you want to provide the question and answer you can make the question as Community wikiBlip
@HakamFostok Why, SO encourage providing both the Q and A during the Q&A creation.Soudan
yes, provide a question and answer, this may be helpful for other. I do NOT have a problem with this, I just suggested to mark the question as community wiki.Blip
@HakamFostok I don't see the whole button to protect this Q&A as community wiki.Soudan
T
7

Provided article has an undocumented expression format. If you use & instead of | to provide multiple traits, you're going to filter tests which match all given traits.

For example:

"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "C:\mytest.dll" /TestCaseFilter:"TestCategory=traitA&TestCategory=traitB&traitN" /logger:trx
Teflon answered 18/12, 2015 at 10:7 Comment(0)
U
0

Yes, that option is missing from the MSDN Page. However it is indeed mentioned in the tool itself. In particular look for the /TestCaseFilter switch from the output of running vstest.console.exe /?

Thank you for reporting this.

Upchurch answered 19/12, 2015 at 22:57 Comment(1)
You're welcome, BTW I believe that this should be a comment instead of an answer :\Soudan

© 2022 - 2024 — McMap. All rights reserved.