2012-07-02 93 views
0

所以我在想,必須有更好的方式通過teamcity爲.net項目運行NUnit測試。目前該項目的構建需要大約10分鐘,測試步驟需要30分鐘。TeamCity以並行方式運行Nunit測試

我在考慮將Nunit測試分成3組,分別分配給不同的代理。然後確保它們在初始構建開始之前對構建依賴。

這是我認爲這樣做的最好方式,是否還有其他方法我也應該考慮?
在旁註意是否可以將所有Nunit測試結合起來,以獲得來自在3個不同機器上構建的測試的一個報告?除非有人想到一個聰明的黑客,否則我不認爲這是可能的。

回答

1

對於並行運行NUnit測試請期待PnUnit在http://www.nunit.org/index.php?p=pnunit&r=2.5和報告您可以配置爲使用log4net的對NUnit的看到這裏舉例:http://www.softwarefrontier.com/2007/09/using-log4net-with-nunit.html

+0

非常感謝,我不知道這些事情! –

+0

這不是PNUnit的目的:「PNUnit不是爲了」隨意「的並行,而僅僅是爲了使測試運行得更快,而是用來測試由分佈式通信組件組成的應用程序。」 – autonomatt

1

我們建立了一個遞歸的MSBuild腳本運行單元測試併發的DLL ,它看起來somelike這樣的:

<Target Name="UnitTestDll"> 
    <Message Text="Testing $(NUnitFile)" /> 
    <ItemGroup> 
     <ThisDll Include="$(NUnitFile)"/> 
    </ItemGroup> 
    <NUnit ToolPath="$(NUnitFolder)" Assemblies="@(ThisDll)" OutputXmlFile="$(TestResultsDir)\%(ThisDll.FileName)-test-results.xml" ExcludeCategory="Integration,IntegrationTest,IntegrationsTest,IntegrationTests,IntegrationsTests,Integration Test,Integration Tests,Integrations Tests,Approval Tests" ContinueOnError="true" /> 
    </Target> 

    <Target Name="UnitTest" DependsOnTargets="Clean;CompileAndPackage"> 
     <Message Text="Run all tests in Solution $(SolutionFileName)" /> 
     <CreateItem Include="$(SolutionFolder)**\bin\$(configuration)\**\*.Tests.dll" Exclude="$(SolutionFolder)\NuGet**;$(SolutionFolder)**\obj\**\*.Tests.dll;$(SolutionFolder)**\pnunit.tests.dll"> 
     <Output TaskParameter="Include" ItemName="NUnitFiles" /> 
     </CreateItem> 
    <ItemGroup> 
     <TempProjects Include="$(MSBuildProjectFile)"> 
     <Properties>NUnitFile=%(NUnitFiles.Identity)</Properties> 
     </TempProjects> 
    </ItemGroup> 
    <RemoveDir Directories="$(TestResultsDir)" Condition = "Exists('$(TestResultsDir)')"/> 
    <MakeDir Directories="$(TestResultsDir)"/> 

    <MSBuild Projects="@(TempProjects)" BuildInParallel="true" Targets="UnitTestDll" /> 
    </Target> 

你顯然還需要你的編譯目標(或在我們的例子CompileAndPackage)實際上首先構建測試的DLL。

這也打亂了你的NUnit的結果爲本地開發商,但在已經打到這個問題,我們寫了一個工具,以幫助與:https://github.com/15below/NUnitMerger