简体   繁体   English

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

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

I'm trying to print the fully qualified name of each test using the dotnet CLI, but it's only showing the test method name.我正在尝试使用dotnet CLI 打印每个测试的完全限定名称,但它只显示测试方法名称。 This list is kind of useless without more qualifiers!如果没有更多的限定词,这个列表就没什么用了!

> 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

I would also be interested in printing the categories for each test.我也有兴趣打印每个测试的类别。

You can use a .runsettings file to define an NUnit section, where you specify the DisplayName format used.您可以使用.runsettings文件来定义 NUnit 部分,您可以在其中指定使用的DisplayName格式。

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

You can use it by calling您可以通过调用使用它

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

I'm trying everything to get this working, but I think it's not currently possible.我正在尽一切努力让这个工作,但我认为目前不可能。 I even tried this runsettings parameter:我什至尝试过这个 runsettings 参数:

DisplayName显示名称

The default for Test Explorer DisplayName is to use the Name of the test, which normally is the method name.测试资源管理器 DisplayName 的默认值是使用测试的名称,通常是方法名称。 Using DisplayName you can change between Name, FullName or FullNameSep.使用 DisplayName,您可以在 Name、FullName 或 FullNameSep 之间进行更改。 The last one will then use the FullNameSeparator, which defaults to ':'.最后一个将使用 FullNameSeparator,默认为“:”。

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

But, that doesn't seem to do the trick.但是,这似乎不起作用。 I don't know what the "Test Explorer" is, but, obviously, it's not working for the dotnet core test adapter.我不知道“测试资源管理器”是什么,但很明显,它不适用于 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