The ability to create a playlist which is defined dynamically was added with update 16.7.0 to Visual Studio 2019.
According to those notes, the playlist User Interface now contains checkboxes for the various selection criteria. The underlying XML seems to be a cascade of <Rule>
elements.
To access the new user interface, it may be necessary to click the new pencil icon (tooltip: edit) in the Test Explorer toolbar, and confirm that the playlist may be updated to the new format.
From the source:
You can also use traits to define a dynamic group by editing the playlist xml file directly.
As of 2020-12-07, I finally got this to work. For the goal to run any test that includes the MSTest Attribute [TestCategory("SchemaUpdateBasic")]
, possibly with other instances of [TestCategory("...")]
<Playlist Version="2.0">
<Rule Name="Includes" Match="Any">
<Property Name="Trait" Value="SchemaUpdateBasic" />
</Rule>
</Playlist>
As of Visual Studio version 16.8.2, this worked as desired. Prior versions resulted, for me, in the correct set of tests appearing in the Test Explorer window, but clicking "Run All" yielding this in Test Output
---------- Starting test discovery for requested test run ---------- Test run will use DLL(s) built for framework
...
========== Test discovery finished: 0 Tests found in 2.6 sec ========== No tests found to run.
Source:
https://learn.microsoft.com/en-us/visualstudio/releases/2019/release-notes#--visual-studio-2019-version-1670
Also https://github.com/MicrosoftDocs/visualstudio-docs/issues/6012 exists as a request for documentation enhancement.