簡體   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