I have the following command line working:
dotnet vstest ...\Platform.UnitTests.dll -lt
And it does show the available tests:
Microsoft (R) Test Execution Command Line Tool Version 15.9.0
Copyright (c) Microsoft Corporation. All rights reserved.
The following Tests are available:
UnitTests.KeyGenerationTests.GenerationServiceTests.GenerateLongTest(min: -9223372036854775807, max: 3722052250456372)
UnitTests.KeyGenerationTests.GenerationServiceTests.GenerateLongTest(min: 0, max: 2818886159009824)
UnitTests.KeyGenerationTests.GenerationServiceTests.GenerateLongTest(min: 1234, max: 3070940396521188)
UnitTests.KeyGenerationTests.GenerationServiceTests.GenerateLongTest(min: -4544123, max: 6717503777496228)
So, I can get the count with the following Powershell command line:
(dotnet vstest ...\Platform.UnitTests.dll -lt | Select-Object -Skip 4 | Measure-Object -Line).Lines
But is it the best way?
E.g. with NUnit I can get an xml file listing all the test cases and counting certain nodes (using XPath) gives us the count of NUnit test cases. I like this one much more, because it does not require me to parse the command output.
So, the question is - can we get the count of tests with vstest.console.exe without parsing the output?
P.S.
Purists might indicate that reading XML involves parsing it. I am fine with that kind of parsing.