您可以使用@ 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