Reputation: 813
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
Upvotes: 4
Views: 1832
Reputation: 64487
Found myself Googling again for this situation, and stumbled across my own unhelpful comment on the other answer...
Basically, all you need to be doing in Cake is calling DotNetCoreTest
with standard settings (nothing specific to TeamCity), and include the following NuGet packages in your test project:
TeamCity.Dotnet.Integration
TeamCity.VSTest.TestAdapter
I also have the Cake build systems module configured in tools\modules\packages.config
:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake.BuildSystems.Module" version="0.3.0" />
</packages>
This will light up the Tests tab in TC.
Upvotes: 5
Reputation: 59923
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")
});
});
Upvotes: 4