2010-11-17 76 views
4

我試圖設置一個NUnit作爲單元測試驅動程序的MSBuild,但腳本在NUnit完成後仍然掛起。它似乎沒有最終確定其工作,並讓MSBuild繼續工作。
我正在使用.NET 4.0並使用NUnit 2.5.8。
如果我手動運行測試或使用gui(VS2010或NUnit),它可以正常運行,但不會在MSBuild調用時運行。NUnit完成後MSBuild掛起

我會感謝任何幫助錯誤發現或只是一個在哪裏尋找答案。

手動命令看起來像這樣:
C:\ ....> NUnit的\ NUnit的-console.exe buildbinaries \ YYYY.XXXX.Extractor.Test.IntegrationTest.dll /xml=nunit.xml

和縮寫的MSBuild:

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> 

    <!-- define folders for build output and reports --> 
    <PropertyGroup> 
    <BuildPath>buildbinaries\</BuildPath> 
    <ReportPath>buildreports\</ReportPath> 
    <ReleaseFolder>release_artefacts\</ReleaseFolder> 
    <PublishFolder>c:\ZZZ Applications\published builds\</PublishFolder> 
    <DeploymentFolder>\\seldclq99\ZZZ_Costanza_Dev$\</DeploymentFolder> 
    </PropertyGroup> 

    <PropertyGroup> 
    <!-- specify assemblies that should be included in coverage report --> 
    <NCoverAssemblyList>YYYY.XXXX.Extractor.Business.dll; YYYY.XXXX.Extractor.Common.dll YYYY.XXXX.Extractor.Configuration.dll YYYY.XXXX.Extractor.DAL.Access.dll YYYY.XXXX.Extractor.DAL.Facade.dll YYYY.XXXX.Extractor.Service.Contracts.dll YYYY.XXXX.Extractor.Service.dll YYYY.XXXX.Extractor.Service.Host.WebHost.dll YYYY.XXXX.Extractor.ServiceGateway.dll</NCoverAssemblyList> 
    </PropertyGroup> 

    <!-- define item group for deliverables --> 
    <ItemGroup> 
    <Binaries Include="$(BuildPath)/**/*.*" Exclude="$(BuildPath)nunit*" /> 
    </ItemGroup> 

    <!-- 
    This is the default target that will be executed if MSBuild is not started 
    with a specific target (this is decided by the DefaultTargets attribute in 
    the root element of this XML document) 
    --> 
    <Target Name="BuildAndTest"> 
    <CallTarget Targets="SetupDirs" /> 
    <CallTarget Targets="Build" /> 
    <CallTarget Targets="UnitAndIntegrationTest" /> 
    <CallTarget Targets="FxCop" /> 
    <CallTarget Targets="CopyToReleaseFolder" /> 
    </Target> 

    <!-- Setup folders used during the build --> 
    <Target Name="SetupDirs"> 
    <RemoveDir Directories="$(ReportPath);$(BuildPath);$(ReleaseFolder)" ContinueOnError="true"/> 
    <MakeDir Directories="$(ReportPath);$(BuildPath);$(ReleaseFolder);$(AssemblyVersionFolder)" ContinueOnError="true"/> 
    </Target> 

    <Target Name="Build"> 
    <!-- build the software using msbuild --> 
    <!-- Build error in the Install build--> 
    <MSBuild ContinueOnError="true" RebaseOutputs="false" Targets="Clean;Rebuild" Projects="YYYYXXXXExtractor.sln" Properties="Configuration=Release;OutDir=..\$(BuildPath)" /> 

    </Target> 

    <!--Run the coverage stats--> 
    <Target Name="UnitAndIntegrationTest"> 
     <Exec Command="nunit\nunit-console.exe buildbinaries\YYYY.XXXX.Extractor.Test.IntegrationTest.dll /xml=$(ReportPath)nunit.xml "/> 
     <CallTarget Targets="UnitTest" /> 
    </Target> 

    <Target Name="UnitTest"> 
     <Exec Command="nunit\nunit-console.exe buildbinaries\YYYY.XXXX.Extractor.Test.UnitTest.dll /xml=$(ReportPath)nunit.xml"/> 
    </Target> 

    <!-- Run FxCop --> 
    <!-- The ForceError.bat fires if the xml file is not found... aka an error was found --> 
    <!-- The quiet command forces an Xml file ONLY if warnings or Errors are found --> 
    <Target Name="FxCop"> 
    <Exec Command="..\tools\fxcop\FxCopCmd.exe /p:..\FxCopSettings.FxCop /o:$(ReportPath)fxcop.xml" /> 
    <Exec Condition="Exists('$(ReportPath)fxcop.xml')" Command="..\tools\fxcop\FX_Cop_Failed_Rule_Checks.bat" /> 

    <!--STATS: Run again but don't fail and this time run for all rules.--> 
    <Exec Command="..\tools\fxcop\FxCopCmd.exe /p:..\FxCopSettingsALLRULES.FxCop /o:$(ReportPath)fxCopAllRules.xml" /> 

    </Target > 

回答

1

,因爲升級到.NET 4的MSBuild似乎在任NUnit的,FxCop的或間歇DOTC掛我已經注意到了生成服務器上類似的行爲通過EXEC命令。如果您檢查任務管理器,則外部執行的命令(例如Nunit.exe)的進程仍處於閒置狀態。如果你手動殺死這個進程,MsBuild繼續它的快樂方式 - 這遠非理想!

這可能是最新版本的MsBuild中的錯誤嗎?我們的構建服務器運行得非常愉快,直到.NET 4升級。

3

我和NUnit 2.5.8有同樣的問題。在nunit網站上有關於測試過程懸掛的一些討論。我切換到NUnit 2.5.7,問題就消失了。

它看起來像幾個星期前在2.5.9

+0

由於未知原因,2.5.7在我們的機器上根本無法啓動。它不會加載nunit.core.dll。所以這對我來說不是一個可行的解決方案。 – 2010-11-22 06:57:18

+0

這個問題在最新的nunit中還沒有解決。如果您有興趣,可以在這裏跟蹤錯誤:https://bugs.launchpad.net/nunitv2/+bug/602761 – 2011-09-02 14:56:33

0

如果你在你的服務器上運行ProcessExplorer,你會注意到一個名爲nunit-agent的帶外進程被產生,最終阻塞了nunit亞軍。

我還沒有驗證,這是固定在2.5.9,但它可能是一些可能有用的信息。

+0

是的,每當我手動終止MSBuild命令提示符時,nunit-agent都會停留。 – 2010-11-22 06:58:53

相關問題