CAKE build and NUNIT3 generating empty results file

人走茶凉 提交于 2021-02-18 22:27:08

问题


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);
    }
});

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.


回答1:


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

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);
    }
});


来源:https://stackoverflow.com/questions/46370959/cake-build-and-nunit3-generating-empty-results-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!