NUnit 3.0 is supported by TeamCity 9.1.x now however you have to install the runner and specify the path to the nunit3.console.exe in the step. My question is where do I copy t
Building on @NikolayP's answer:
- Add reference to the NuGet package (https://www.nuget.org/packages/NUnit.Runners/).
- To restore package you could use "NuGet Installer" build step, see following blog post: https://blog.jetbrains.com/teamcity/2013/08/nuget-package-restore-with-teamcity/
- After that you just set path like "packages\NUnit.Console.3.0.0\tools\nunit3-console.exe" from the restored NuGet package.
I wrote the following PowerShell script to determine the correct NUnit.ConsoleRunner package directory and populate a TeamCity variable before the NUnit task is run. It uses the most recent version of the NUnit.Console package.
$SrcDirectory = "%src.directory%"
$PackagesDirectory = Join-Path $SrcDirectory packages
$NUnitConsoleRunnerPackageDirectory = Get-ChildItem (Join-Path $PackagesDirectory NUnit.ConsoleRunner.*) | %{
@{
Directory = $_.FullName
Version = [Version]::Parse(($_.Name -replace "NUnit.ConsoleRunner.",""))
}
} | Sort-Object Version -Descending | Select-Object -First 1 | %{ $_.Directory }
if (!$NUnitConsoleRunnerPackageDirectory) {
throw [IO.DirectoryNotFoundException] "NUnit console runner package directory not found"
}
Write-Output "##teamcity[setParameter name='nunit.consolerunner.directory' value='$NUnitConsoleRunnerPackageDirectory']"
Note that you'll need to define the src.directory
variable to point to the directory that contains the packages
directory on your build agent, or otherwise supply the necessary root directory for the PowerShell script to work. You'll also need to define the nunit.consolerunner.directory
variable with a default value of empty.
The script will also throw an exception if, for whatever reason, an NUnit.ConsoleRunner directory could not be found.
Also you could follow this instruction: https://confluence.jetbrains.com/display/TCD9/Getting+Started+with+NUnit