繁体   English   中英

如何按全名列出 NUnit 3 测试?

[英]How do I list NUnit 3 tests by their FullName?

我正在尝试使用dotnet CLI 打印每个测试的完全限定名称,但它只显示测试方法名称。 如果没有更多的限定词,这个列表就没什么用了!

> dotnet test -t MyTestLibrary.dll
Test run for MyTestLibrary.dll(.NETCoreApp,Version=v2.2)
Microsoft (R) Test Execution Command Line Tool Version 15.9.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The following Tests are available:
    Test1
    Test1
    Test1

我也有兴趣打印每个测试的类别。

您可以使用.runsettings文件来定义 NUnit 部分,您可以在其中指定使用的DisplayName格式。

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <NUnit>
      <DisplayName>FullNameSep</DisplayName>
  </NUnit>
</RunSettings>

您可以通过调用使用它

dotnet test -t MyTestLibrary.dll --settings test.runsettings

我正在尽一切努力让这个工作,但我认为目前不可能。 我什至尝试过这个 runsettings 参数:

显示名称

测试资源管理器 DisplayName 的默认值是使用测试的名称,通常是方法名称。 使用 DisplayName,您可以在 Name、FullName 或 FullNameSep 之间进行更改。 最后一个将使用 FullNameSeparator,默认为“:”。

https://docs.nunit.org/articles/vs-test-adapter/Tips-And-Tricks.html#displayname

但是,这似乎不起作用。 我不知道“测试资源管理器”是什么,但很明显,它不适用于 dotnet 核心测试适配器。

$ dotnet test -t -- NUnit.DisplayName=FullName
Test run for C:\Users\anthony\...\MyTestLibrary.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.6.0
Copyright (c) Microsoft Corporation.  All rights reserved.

The following Tests are available:
    Test1
    Test1
    Test1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM