我使用NUnitConsole3测试运行器运行所有unittest.dll,并在成功构建后生成xml TestResult报告。如果任何单元测试失败,我将如何使构建失败?
以下是运行单元测试的脚本
$SourceDir = "C:\Users\M1036083\Source\Repos\TestSitecoreProject"
$OutDir = "C:\Builds\2\Demo\bin"
## ------------------------------------------------------------------------------
## Set Nunit Tool path
## ------------------------------------------------------------------------------
$nunit = "$SourceDir\NUnit.Console-3.6.1\nunit3-console.exe"
## ------------------------------------------------------------------------------
## Get all the Test dlls from the output directory
## ------------------------------------------------------------------------------
$tests = (Get-ChildItem $OutDir -Recurse -Include Demo.*Tests.dll)
## ------------------------------------------------------------------------------
## Run all the tests and generate report in XML format
## ------------------------------------------------------------------------------
& $nunit --inprocess $tests --noheader --work="$OutDir"