NUnit で複数のテストアセンブリをテストする (CUI編)
NUnit で複数のテストアセンブリをテストする (GUI編) - お だ のスペース の続きです。
今度は CUI で試してみます。
まずは、お手軽に前回作成した NUnit プロジェクトファイル(.nunit ファイル)を使います。
こんな感じのコマンドを実行します。
nunit-console.exe 〜\ClassLibrary1.nunit /xml=〜\TestResult.xml
結果ファイルを見てみましょう。二つのテストアセンブリの結果が出力されてますね!
<?xml version="1.0" encoding="utf-8" standalone="no"?> <!--This file represents the results of running a test suite--> <test-results name="C:\Users\user\Desktop\ClassLibrary1.nunit" total="4" errors="0" failures="0" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2012-01-13" time="22:00:50"> <environment nunit-version="2.5.9.10348" clr-version="2.0.50727.5448" os-version="Microsoft Windows NT 6.1.7601 Service Pack 1" platform="Win32NT" cwd="C:\Program Files (x86)\NUnit 2.5.9\bin\net-2.0" machine-name="DOTNET-PC" user="User" user-domain="ODA" /> <culture-info current-culture="ja-JP" current-uiculture="ja-JP" /> <test-suite type="Project" name="C:\Users\user\Desktop\ClassLibrary1.nunit" executed="True" result="Success" success="True" time="0.109" asserts="0"> <results> <test-suite type="Assembly" name="C:\Users\user\Desktop\..\bitbucket\payment\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll" executed="True" result="Success" success="True" time="0.062" asserts="0"> <results> <test-suite type="Namespace" name="ClassLibrary1" executed="True" result="Success" success="True" time="0.062" asserts="0"> <results> <test-suite type="TestFixture" name="Class1Test" executed="True" result="Success" success="True" time="0.062" asserts="0"> <results> <test-case name="ClassLibrary1.Class1Test.Multiply1" executed="True" result="Success" success="True" time="0.047" asserts="1" /> <test-case name="ClassLibrary1.Class1Test.Multiply2" executed="True" result="Success" success="True" time="0.000" asserts="1"> <categories> <category name="B" /> </categories> </test-case> </results> </test-suite> </results> </test-suite> </results> </test-suite> <test-suite type="Assembly" name="C:\Users\user\Desktop\..\bitbucket\payment\ClassLibrary1\ClassLibrary2\bin\Debug\ClassLibrary2.dll" executed="True" result="Success" success="True" time="0.000" asserts="0"> <results> <test-suite type="Namespace" name="ClassLibrary2" executed="True" result="Success" success="True" time="0.000" asserts="0"> <results> <test-suite type="TestFixture" name="Class1Test" executed="True" result="Success" success="True" time="0.000" asserts="0"> <results> <test-case name="ClassLibrary2.Class1Test.Add1" executed="True" result="Success" success="True" time="0.000" asserts="1"> <categories> <category name="A" /> </categories> </test-case> <test-case name="ClassLibrary2.Class1Test.Add2" executed="True" result="Success" success="True" time="0.000" asserts="1" /> </results> </test-suite> </results> </test-suite> </results> </test-suite> </results> </test-suite> </test-results>
では、.nunit ファイルを使わない場合はこんな感じです。
nunit-console.exe 〜\Test1.dll 〜\Test2.dll /xml=〜\TestResult.xml
結果ファイルも先ほどとほぼ同じで、二つのテストアセンブリの結果が出力されています。
<?xml version="1.0" encoding="utf-8" standalone="no"?> <!--This file represents the results of running a test suite--> <test-results name="C:\temp\ClassLibrary1.dll" total="4" errors="0" failures="0" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2012-01-13" time="22:07:49"> <environment nunit-version="2.5.9.10348" clr-version="2.0.50727.5448" os-version="Microsoft Windows NT 6.1.7601 Service Pack 1" platform="Win32NT" cwd="C:\Program Files (x86)\NUnit 2.5.9\bin\net-2.0" machine-name="DOTNET-PC" user="User" user-domain="ODA" /> <culture-info current-culture="ja-JP" current-uiculture="ja-JP" /> <test-suite type="Test Project" name="" executed="True" result="Success" success="True" time="0.819" asserts="0"> <results> <test-suite type="Assembly" name="C:\temp\ClassLibrary1.dll" executed="True" result="Success" success="True" time="0.109" asserts="0"> <results> <test-suite type="Namespace" name="ClassLibrary1" executed="True" result="Success" success="True" time="0.086" asserts="0"> <results> <test-suite type="TestFixture" name="Class1Test" executed="True" result="Success" success="True" time="0.083" asserts="0"> <results> <test-case name="ClassLibrary1.Class1Test.Multiply1" executed="True" result="Success" success="True" time="0.054" asserts="1" /> <test-case name="ClassLibrary1.Class1Test.Multiply2" executed="True" result="Success" success="True" time="0.001" asserts="1"> <categories> <category name="B" /> </categories> </test-case> </results> </test-suite> </results> </test-suite> </results> </test-suite> <test-suite type="Assembly" name="C:\temp\ClassLibrary2.dll" executed="True" result="Success" success="True" time="0.092" asserts="0"> <results> <test-suite type="Namespace" name="ClassLibrary2" executed="True" result="Success" success="True" time="0.072" asserts="0"> <results> <test-suite type="TestFixture" name="Class1Test" executed="True" result="Success" success="True" time="0.069" asserts="0"> <results> <test-case name="ClassLibrary2.Class1Test.Add1" executed="True" result="Success" success="True" time="0.051" asserts="1"> <categories> <category name="A" /> </categories> </test-case> <test-case name="ClassLibrary2.Class1Test.Add2" executed="True" result="Success" success="True" time="0.001" asserts="1" /> </results> </test-suite> </results> </test-suite> </results> </test-suite> </results> </test-suite> </test-results>