0

我有以下命令行工作:

dotnet vstest ...\Platform.UnitTests.dll -lt

它确实显示了可用的测试:

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)

因此,我可以使用以下 Powershell 命令行获取计数:

(dotnet vstest ...\Platform.UnitTests.dll -lt | Select-Object -Skip 4 | Measure-Object -Line).Lines

但这是最好的方法吗?

例如,使用 NUnit,我可以获得一个列出所有测试用例的 xml 文件,并计算某些节点(使用 XPath)为我们提供 NUnit 测试用例的计数。我更喜欢这个,因为它不需要我解析命令输出。

所以,问题是 - 我们可以在不解析输出的情况下使用 vstest.console.exe 获得测试计数吗?

附言

纯粹主义者可能会指出读取 XML 涉及解析它。我对这种解析很好。

4

0 回答 0