CAKE构建和NUNIT3生成空结果文件 [英] CAKE build and NUNIT3 generating empty results file

查看:58
本文介绍了CAKE构建和NUNIT3生成空结果文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Cake build并尝试将蛋糕单元测试结果上传到AppVeyor,但是Cake/Nunit3在本地运行时会生成空结果,并且我认为这是导致AppVeyor错误的原因.在下面的块中,将生成NUnitResults.xml,但始终为空.

I'm using cake build and trying to upload the cake unit test results to AppVeyor, but Cake/Nunit3 are generating empty results when I run locally and I assume that is what is causing my errors on AppVeyor. In the below block, NUnitResults.xml is generated but always empty.

Task("UnitTest")
.IsDependentOn("Build")
.IsDependentOn("Setup")
.Does(() => {
    var resultsFile = artifactsDirectory + "/NUnitResults.xml";
    NUnit3("./StatusPageIo/StatusPageIo.UnitTests/bin/Release/StatusPageIo.UnitTests.dll", new NUnit3Settings()
    {
        OutputFile = resultsFile,           
    });

    if(AppVeyor.IsRunningOnAppVeyor)
    {
        AppVeyor.UploadTestResults(resultsFile, AppVeyorTestResultsType.NUnit3);
    }
});

我知道测试正在运行,因为当我在本地运行build.ps1时,我看到了测试输出,但是由于某种原因,我特定输出文件的测试输出为空.如果我将NoResults显式设置为false,则将获得TestResults.xml文件,但在项目的根目录中,而不是在 resultsFile 路径中.

I know the tests run because when I run build.ps1 locally I see test output, but for whatever reason the test output for my specific output file is empty. If I explicitly set NoResults to false, I get a TestResults.xml file but in the root of the project, not in the resultsFile path.

推荐答案

OutputFile 是保存通常会写入控制台的任何测试输出的路径.

OutputFile is the path to save any test output which would normally be written to console.

您正在寻找 Results -您可以在其中指定写入测试结果的路径.试试这个:

You're looking for Results - where you can specify a path to write the test results. Try this:

Task("UnitTest")
.IsDependentOn("Build")
.IsDependentOn("Setup")
.Does(() => {
    var resultsFile = artifactsDirectory + "/NUnitResults.xml";
    NUnit3("./StatusPageIo/StatusPageIo.UnitTests/bin/Release/StatusPageIo.UnitTests.dll", new NUnit3Settings()
    {
        Results = new[] { new NUnit3Result { FileName = resultsFile } },           
    });

    if(AppVeyor.IsRunningOnAppVeyor)
    {
        AppVeyor.UploadTestResults(resultsFile, AppVeyorTestResultsType.NUnit3);
    }
});

这篇关于CAKE构建和NUNIT3生成空结果文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆