Viewing log4net output when running nunit tests in teamcity - nunit

I'm setting up some selenium tests written in C# to run in teamcity. The tests output various info when running, I have a log4net rolling file appender on the project and when they run locally in VS or using the nunit test runner they write to a log file correctly. When running in teamcity this doesn't happen. Is it possible to get this working?
TeamCity version: 9.0.3
TeamCity Nunit runner: 2.6.4

Yes, TeamCity's build log is actually the console output, so you need to use log4net's ConsoleAppender.
Have a look at an example here on how to configure it.
https://logging.apache.org/log4net/release/config-examples.html
Also log4net allows multiple appenders to be used, so you can keep the rolling file appender as well if needed.

Related

Teamcity Gives error while running Nunit runner : Has no Text Fixture

I am trying to run some unit tests in teamcity build configuration. I am using NUnit.ConsoleRunner.3.6.1 . However It says "Has no TestFixture". But when I tried to run it in command prompt using same runner it completed successfuly. What are the possible reasons ?
Really, more info is needed to judge what your problem is. However, most errors of that type indicate that the nunit framework has not been deployed with the test assembly that uses it.

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