您可以使用@ jpoh的方法,但在TestSetup方法中執行該方法,這將需要您按照每個燈具進行操作。如果確實需要的話,你可以編寫一個基類,所有你的測試裝置從實現這個方法的繼承。
另一種解決方案是使用MSBuild運行NUnit並使用MSBuildCommunityTasks庫中的任務。這允許你繼續出錯,並從NUnit獲取錯誤代碼。你不會得到什麼方法導致問題,但可能會幫助一些。這是我的MSBuild目標:
<Target Name="UnitTest"
DependsOnTargets="BuildIt">
<NUnit Assemblies="@(TestAssemblies)"
ToolPath="$(NUnitx86Path)"
WorkingDirectory="%(TestAssemblies.RootDir)%(TestAssemblies.Directory)"
OutputXmlFile="@(TestAssemblies->'%(FullPath).$(NUnitFile)')"
Condition="'@(TestAssemblies)' != ''"
ExcludeCategory="$(ExcludeNUnitCategories)"
ContinueOnError="true">
<Output TaskParameter="ExitCode" ItemName="NUnitExitCodes"/>
</NUnit>
<!-- Copy the test results for the CCNet build before a possible build failure (see next step) -->
<CallTarget Targets="CopyTestResults" Condition="'@(TestAssemblies)' != ''"/>
<Error Text="Test error(s) occured" Code="%(NUnitExitCodes.Identity)" Condition=" '%(NUnitExitCodes.Identity)' != '0' And '@(TestAssemblies)' != ''"/>
</Target>
這可能不會滿足您的需要,但是可以嘗試和玩。
這就是說,我會同意@rifferte,這聽起來像你需要在本地調試問題,而不是依靠CC.NET來處理報告。
此方法使用起來很繁瑣,因爲必須修改每個測試以包含這些行。 – user95319 2009-07-13 22:46:13