Visual Studio 2010 プロジェクトをビルドするときに、NUnit で単体テストを実行し、一部のテストが失敗した場合にのみテスト結果を表示したいと考えています。
以下のようなバッチ ファイルを呼び出すために、Visual Studio でビルド後のイベントをセットアップしました。
$(ProjectDir)RunUnitTest.bat "$(SolutionDir)packages\NUnit.Runners.2.6.0.12051\tools\nunit-console.exe" "$(TargetPath)"
次に、テスト プロジェクト dllRunUnitTest.batを呼び出して渡します。nunit-console.exe
@echo off    
REM runner is the full path to nunit-console.exe
set runner=%1    
REM target is the full path to the dll containing unit tests
set target=%2    
"%runner%" "%target%"    
if errorlevel 1 goto failed
if errorlevel 0 goto passed    
:failed
echo some tests failed
goto end    
:passed
echo all tests passed
goto end    
:end
echo on
その後、NUnit はTestResult.xmlテスト結果を含むものを生成するので、ユーザー フレンドリーな方法で表示するにはどうすればよいでしょうか? Visual Studio 内に表示するのがベストですが、他のオプションも開いています。