4

I am using Cake as a build script and TeamCity for CI. I am having Cake run unit tests with NUnit and then TeamCity is pulling in those results with a 'xml report processor'.

As you can see its importing the file, but the 'Test' tab is missing so I can't see the test output.

Am I missing a step?

Gary Ewan Park
  • 17,610
  • 5
  • 42
  • 60
Andrew Davis
  • 460
  • 3
  • 17

4 Answers4

2

My cake task for testing is just this and the Tests report tab appears

NUnit3(testsDir.ToString() + "/*Tests.dll", new NUnit3Settings
{
    NoResults = true,
    NoHeader = true,
    Framework = "net-4.0",
    Workers = 5,
    Timeout = 10000
});

Do you really need the report xml?

pitermarx
  • 908
  • 1
  • 9
  • 22
  • This is relying on NUnit built in ability to detect that it is running on TeamCity and to provide the correct service messages to upload the test results, right? – Gary Ewan Park Jul 28 '16 at 11:47
  • 2
    For versions newer than 3.4 you need to add `#tool "nuget:?package=NUnit.Extension.TeamCityEventListener"` https://github.com/nunit/docs/issues/78 – Lukas Pirkl Feb 07 '17 at 15:40
2

It was an issue with the nunit-console. I downgraded to 3.2.1 and it works now.

Andrew Davis
  • 460
  • 3
  • 17
  • Thanks for reporting back on this one. It might be worth updating the original question with this solution, or marking it as the accepted answer. – Gary Ewan Park Aug 01 '16 at 18:58
1

It looks to me like your tests failed to execute properly (as opposed to executing properly with a failing test). Try running the build locally, then check the contents of the TestResult.xml file.

If that looks good, change the project settings on TC to save the xml file as an artifact and compare what you see there with your successful local run.

Finally, ensure that the type of XML report in the TC config is set to NUnit.

Hope this helps, Mark

Mark
  • 580
  • 3
  • 11
  • Thanks for that Mark. Unfortunately the test intentionally failed to try I introduced a failing test to see if the report generated when there was an issue. I can confirm that the TestResult.xml looks good and matches what I expect. I still doesn't want to work – Andrew Davis Jul 28 '16 at 13:51
0

I got a similar problem when Teamcity 9.X not able to load nunit 3 xml because older version of teamcity report parser build feature does not understand that format.

I get it working by converting the nunit result to xunit link to the xslt! and the import the file as junit result.

Task("Run-Unit-Tests")  
.Does(() =>
{
    DotNetCoreTest("./Project");        
}).Finally(() =>
{  
    XmlTransform("./nunit3-xunit.xslt", "./TestResult.xml", "./NUnit.WebApp.FunctionnalTests.TestResult.xml");
    if(TeamCity​.IsRunningOnTeamCity)
    {       
        TeamCity.ImportData("junit","./NUnit.WebApp.FunctionnalTests.TestResult.xml");
    }  
});
jboo
  • 364
  • 6
  • 14