【问题标题】:How do I add Hyperlinking in NUnit Test Output?如何在 NUnit 测试输出中添加超链接?
【发布时间】:2022-12-10 17:31:55
【问题描述】:

我希望能够在单元测试的输出中添加指向相关数据的超链接。

我有以下测试:

using NUnit.Framework;

namespace BioFire.PanelSoftware.Service.Tests
{
    [TestFixture]
    public class SimpleTest
    {
        [Test]
        public void Test1()
        {
            Console.WriteLine("www.google.com"); //not hyperlink
            Console.WriteLine(@"C:\Program Files"); //not hyperlink
            throw new Exception("My output window will somehow give me a hyperlink to here.");
        }
    }
}

根据this question,在 C# 中是不可能的。但它显然以某种方式为 nUnit 工作:

【问题讨论】:

    标签: c# output nunit


    【解决方案1】:

    这非常特定于您正在使用的终端,我不相信 C# 中的任何内容都可以实现可点击的文本。从技术上讲,您可以使用 System.Diagnostics 命名空间中的 Process.Start() 来触发默认浏览器打开您想要的网页,但这不是超链接,而是由您的规范触发

    如果您从 IDE 中运行,则必须查看底层 shell 并尝试将其换成不同的配置文件(例如,这在 VS Code 上应该很容易,但我不确定 Visual Studio 是否可以支持它) .如果您从 cmd 行运行,请尝试使用新的 Windows Terminal App 作为它 supports this functionality

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-23
      • 2010-10-06
      • 2015-12-05
      • 2015-07-08
      • 2018-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多