TeamCity XML Report Processing not working for NUnit 3 report file - nunit

I have a CakeBuild build script which compiles a Visual Studio 2015 solution then uses the Cake add in for NUnit 3 to run the unit tests and generate the TestResult.xml file. The tests pass successfully when run locally and the report is generated.
This same build script is being run by TeamCity (version 10.0.2), with the build agent also successfully running the tests (all passing) and the TestReport.xml file being generated.
The TeamCity build configuration has been configured via the XML Report Processing Build Feature to import the NUnit report. The build log suggests this has also occurred successfully. Example of the log:
[10:06:41]NUnit report watcher
[10:06:41][NUnit report watcher] 1 report found for paths:
[10:06:41][NUnit report watcher] **/TestResult.xml
[10:06:41][NUnit report watcher] Successfully parsed
[10:06:41][Successfully parsed] 1 report
[10:06:41][Successfully parsed] build\TestResult.xml
However, there is no reference to any of the tests in the build run - the Test tab is missing completely and no other references to the tests at all.
Is there anything else that needs to be configured to get the test results to show up?

We've had the same issue and found the solution in https://github.com/nunit/teamcity-event-listener/issues/39
Main point is to make sure to include the package NUnit.Extension.TeamCityEventListener which reports the results to TeamCity.
In addition the Nunit Runner Settings should include
NUnit3(path, new NUnit3Settings {
TeamCity = true
});

Related

No code coverage generated from ReportGenerator in Azure DevOps

I am using the ReportGenerator task in my Azure DevOps build to generate a code coverage report. The problem is that the generated report is empty.
In my VsTest task that runs the unit tests I have checked the option Code coverage enabled. The .coverage file is correctly generated and the unit tests are all successfully run. However, the generated code coverage report shows that no code was covered by any of the unit tests.
Here is a screenshot of my code coverage Report Generator task.
And here is the output from the code coverage report.
Here is a screenshot of the Azure DevOps log file for the task showing that it executed correctly without any errors.
Interestingly the log does show the following
Analyzing 0 classes
Is this because ReportGenerator cannnot find the assemblies / classes? I've tried specififying a value for Source directories but this has made no difference.
Why is the code coverage report showing no code coverage?
ReportGenerator can not handle .coverage files.
You can find the supported formats here: https://github.com/danielpalme/ReportGenerator#supported-input-and-output-file-formats
You can use a tool like OpenCover or coverlet to generate a coverage report in a format that ReportGenerator is able to parse.
Or you can convert the .coverage file format. Here you find instructions how this can be done: https://github.com/danielpalme/ReportGenerator/wiki/Visual-Studio-Coverage-Tools

NUnit not working on teamcity agent in docker

I am running teamcity server and agent in a docker container (https://blog.jetbrains.com/teamcity/2016/06/teamcity-on-docker-hub-its-official-now/). I am trying to build dotnet core application. I have 3 build steps as "dotnet restore", "dotnet build" and "dotnet test"
The build step completed successfully but i am unable to see "tests" tab on the build.
Do i need to configure something or i need to use a different runner i.e. nunit to get the test result on the screen?
You are running your tests correctly, but the NUnit dotnet-test-nunit runner doesn't currently include or support the TeamCity command line option or integration. See https://github.com/nunit/dotnet-test-nunit/issues/72
TeamCity added custom code to NUnit to support their style of integration. In retrospect, the NUnit team regrets doing this and has moved it out to an extension for the main NUnit runner that is maintained by TeamCity. Because of this, we are reluctant to add the custom code back into dotnet-test-nunit for TeamCity when no other CI system requires it, but TeamCity is popular, so it may happen.
I don't use TeamCity so I can't help with alternatives. Do your failing tests fail the build? If so, can you live with just viewing the console output for the results of your tests?

How to build and run nunit scripts integrated in visual Studio via quickbuild

My quick build has three steps:
Repository : Which is checking out the source from svn - running fine
Run the nunit script via devenv.com and generate the abc.xml file - NOT WORKING
Publish the report from that abc.xml - running fine with one sample xml
Could you help with this 2nd step?
i.e generating .xml automatically via quickbuild from nunit test cases.
Please use the NUnit console runner like this:
nunit-console /result:console-test.xml nunit.tests.dll
More information on the runner can be found here: http://www.nunit.org/index.php?p=consoleCommandLine&r=2.6.2

Process NUnit result.xml and show it in Team City Web GUI

I remember doing this in an older version of Team City in which the NUnit Runner failed, so I tried running NUnit using the Command Line Runner instead.
I think there was an option in the Command Line Runner settings which let you specify the kind of output file: NUnit result.xml was one of them. Doing this, you could see the test result breakdown in the Web GUI, just like when the NUnit Runner worked.
But I don't see this in the latest Team City (6.5.5). Can it still be done?
PS: Before anyone asks, I can't use Team City's NUnit Runner because NUnit has a bug which will be fixed in the soon to come 2.6.0 version. Said bug does not occurr when running nunit-console
This could be done using importdata TeamCity message, this is really helpful when you are running NUnit tests manually executing nunit-console.exe from an MSBuild script, for instance using NUnit MSBuild Community Task, but keep in mind that TeamCity provides built in NUnit tests runner so you do not need this low level TeamCity scripting. Anyway you can import report in this way:
<Message
Text="##teamcity[importData type='nunit' path='...\TestResults.xml']"
Importance="High"/>
See Importing XML Reports
If you prefer to run code coverage, code inspection, test tools or
duplicate finders directly from build script, not as a build runner,
you can use the importData service messages to import generated xml
reports into TeamCity.
The functionality was still there, found it by accident when looking at another build configuration. Importing an XML is now a "Build Feature", see:

Running NUnit Tests from Team city

I've successfully managed to get MSTests running for each of the builds on our TeamCity Server.
I've got a couple of projects that use NUnit, so was hoping that getting TeamCity to run NUnit tests would be as simple as running MSTests:
So when I try to do the same for my NUnit Tests the Testing Tab doesn't show up when the Build finishes, so I'm guessing it hasn't run my tests.
Does anyone know what I'm doing wrong?
Not sure if this will help, but this is from the build log:
[Project "AssemblyName.proj.teamcity.patch.tcprojx" (Build;TeamCity_Generated_NUnitTests target(s)):] C:\Program Files\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe "##" "C:\Program Files\TeamCity\buildAgent\temp\buildTmp\tmp2867.tmp"
[13:22:57]: Start TeamCity NUnit Test Runner
[13:22:59]: Build finished
It's like it starts the nunit build runner, then just stops?
Thanks
Dave
NUnit test assemblies path is resolved relative to solution file folder. Try adding %teamcity.build.checkoutDir% at the beginning.
Have you checked out the TeamCity Addin for NUnit?
http://confluence.jetbrains.net/display/TCD4/TeamCity+Addin+for+NUnit