Search code examples
c#teamcity.net-corecakebuild

Exporting Cake dotnet core test output to TeamCity


I'm looking for a way to export the test output from a .NET Core application, to TeamCity via a Cake build script.

Currently, I'm simply running:

DotNetCoreTest("./src/MyTestProject");

But I can't see anything within the documentation of ITeamCityProvider or DotNetCoreTest

The above code block works from the command line, but I can't find a way to publish the test results to the build server.

Hope someone can help


Solution

  • With the NUnit test runner for .NET Core, you need to explicitly pass the --teamcity option to have it report the test results to TeamCity (see commit 323fb47).

    In your Cake script, you can do that by using the ArgumentCustomization property:

    Task("Test")
       .Does(() =>
    {
        DotNetCoreTest(
            "path/to/Project.Tests",
            new DotNetCoreTestSettings
            {
                ArgumentCustomization = args => args.Append("--teamcity")
            });
    });