I am using James Kovacs approach using TeamCity in my project.
It allows using the same build script and its targets:
- from PowerShell on developer machine before code commit
- from TeamCity on independent server after code was commit to source control
One of the topic is to run the TASK from build script using MsBuild runner. The TASK executes NUnit and TC shows Test report after test execution.
Build script code
<Target Name="Compile" DependsOnTargets ="Init" >
<MSBuild Projects="@(SolutionFile)" Targets ="Rebuild" Properties="OutDir=%(Buildartifacts.FullPath); Configuration=$(Configuration)"/>
<Target Name="NUnit" DependsOnTargets ="Compile">
<Exec Command="@(NUnit) @(TestAssembly) /xml=@(TestResult)" />
Team City runner configuration is attached. See TCConf.png
This configuration shows the build and tests were run on independent tab. In TC version 9.0 you ‘ve removed “Run NUnit test” option to independent Runner type that can be included as a step to build process.
This approach is not suitable for me because I can’t use it from PowerShell.
There is another case to use NUnit tast inside build script.
<UsingTask TaskName="NUnit" AssemblyFile="$(teamcity_dotnet_nunitlauncher_msbuild_task)"/>
This approach automatically includes test report to the build result. But I can’t use it from PowerShell. (An error occurred of parsing teamcity_dotnet_nunitlauncher_msbuild_task variable)
So my question is.
How can I use James Kovacs approach, based on NUnit execution using "Exec" command from MsBuild runner in TC version 9.0, to show Test report?
Thank you for your help.