【问题标题】:Setting "allure-results" directory to current working directory将“allure-results”目录设置为当前工作目录
【发布时间】:2019-03-13 12:28:58
【问题描述】:

我在更改保存我的诱惑结果的位置时遇到了一些问题。

我创建了一个 allureConfig.json 文件,其中包含以下内容

"allure": {
"title": "Test Results",
"directory": "allure-results",
 }

在使用 Nunit 执行测试时,我还配置了当前工作目录

    [Before]
    public void Init()
    {
        var dir = Path.GetDirectoryName(GetType().Assembly.Location) ?? throw new InvalidOperationException();

        Directory.SetCurrentDirectory(dir);
    }

但是,allure-results 文件夹仍然需要在 %temp% 中创建,而不是在锻炼文件夹中。

如果我在 JSON 文件中对地址进行硬编码,那么这是可行的,这显然不是一个永久的解决方案。

我无法为这个问题找到一个干净可用的工作解决方案。

非常感谢任何帮助。

【问题讨论】:

    标签: c# nunit specflow allure


    【解决方案1】:

    Environment.CurrentDirectory 适合我。

        [BeforeTestRun]
        public static void BeforeTestRun()
        {
            //Set default working directory for NUnit to store allure results
            Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        }
    

    【讨论】:

    • 这对我不起作用,该文件夹仍在默认临时目录中创建
    • 我发现如果您通过命令行使用 nunit3-console.exe 运行测试,则上述工作正常并且测试结果可以在相关目录中找到。但是在 Visual Studio 中通过测试资源管理器运行时,这似乎被覆盖或忽略了。
    • 您可能缺少 Nuget 包“NUnit 3 测试适配器”marketplace.visualstudio.com/…,它允许通过 Visual Studio 运行 NUnit 测试。否则,您使用 MSTest。
    • 我已安装此适配器,但仍在错误位置创建文件夹。我可以从测试输出中看到正在使用适配器。 NUnit Adapter 3.13.0.0:测试执行开始
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-21
    • 1970-01-01
    相关资源
    最近更新 更多