NUnit.Engine.NUnitEngineUnloadException:遇到多个异常。检索AggregatedExceptions属性以获取更多信息

时间:2018-08-08 12:46:53

标签: nunit

在构建服务器TeamCity上运行测试时,我在日志中得到[主题],并且步骤失败。

代码是大量代码的结果,这使得很难准确地查明我在做错什么(我宁愿不回滚更改,也不要一步一步地做一遍)。

我该如何解决?我该如何找出问题所在?

我在跑步 -nunit nuget 3.10.1(撰写本文时为最新官员) -使用x64 / v4.0的构建服务器上的nunit.console 3.8.0

在我的开发机上本地运行(通过R#),我看不到任何问题。

测试是基于数据库的测试,我在其中为测试(案例)创建一个新数据库,然后在测试完成后将其删除。

欢迎任何建议!

BR-安德斯

[14:31:35]Step 3/6: NUnit - non-selenium (NUnit) (1m:05s)
[14:32:41]Step 4/6: OctopusDeploy: Create release (8s)
[14:32:50]Step 5/6: OctopusDeploy: Deploy release CI (OctopusDeploy: Deploy release) (1m:02s)
[14:33:52]Step 6/6: NUnit - selenium (NUnit) (1m:24s)
[14:33:53][Step 6/6] Starting: C:\TeamCity\buildAgent\tools\JetBrains.dotCover.CommandLineTools.bundled\dotCover.exe cover C:\TeamCity\buildAgent\temp\buildTmp\eBhHYI0b3Hab7OnsiQarKgWFi56r6tlg.dotCover /ReturnTargetExitCode /NoCheckForUpdates
[14:33:53][Step 6/6] in directory: C:\TeamCity\buildAgent\work\f7928b43a423b8ff\Src\JCI.ITC.COMP2.Search.IntegrationTests
[14:33:53][Step 6/6] JetBrains dotCover Console Runner 2017.2.2. Build 109.0.20171006.131113
[14:33:53][Step 6/6] Copyright (c) 2009-2018 JetBrains s.r.o. All rights reserved.
[14:33:54][Step 6/6] [JetBrains dotCover] Coverage session started [08-08-2018 14:33:54]
[14:33:57][Step 6/6] Runtime Environment
[14:33:57][Step 6/6]    OS Version: Microsoft Windows NT 10.0.14393.0
[14:33:57][Step 6/6]   CLR Version: 4.0.30319.42000
[14:33:57][Step 6/6] 
[14:33:57][Step 6/6] Test Files
[14:33:57][Step 6/6]     C:\TeamCity\buildAgent\temp\buildTmp\eWgQASs1HMWflTd4lND2sWNURPc3yFDs.nunit
[14:33:57][Step 6/6] 
[14:33:57][Step 6/6] Test Filters
[14:33:57][Step 6/6]     Where: cat==Integration
[14:33:57][Step 6/6] 
[14:34:03][Step 6/6] JCI.ITC.COMP2.Search.IntegrationTests.dll (52s)
[14:35:12][Step 6/6] 
[14:35:12][Step 6/6] Tests Not Run
[14:35:12][Step 6/6] 
[14:35:12][Step 6/6] 1) Ignored : JCI.ITC.COMP2.Search.IntegrationTests.CoreSolver.Integration.IntegrationUsingHandlerDirectlyTest.ThatPostingValidCalculationIsSuccesful
[14:35:12][Step 6/6] Second wave
[14:35:12][Step 6/6] 
[14:35:12][Step 6/6] 2) Ignored : JCI.ITC.COMP2.Search.IntegrationTests.CoreSolver.Integration.SeleniumTests.ThatSwaggerPageCanBeDisplayedCorrectly
[14:35:12][Step 6/6] OneTimeSetUp: Waiting
[14:35:12][Step 6/6] 
[14:35:12][Step 6/6] Run Settings
[14:35:12][Step 6/6]     RuntimeFramework: net-4.0
[14:35:12][Step 6/6]     DisposeRunners: True
[14:35:12][Step 6/6]     WorkDirectory: C:\TeamCity\buildAgent\work\f7928b43a423b8ff\Src\JCI.ITC.COMP2.Search.IntegrationTests
[14:35:12][Step 6/6]     BasePath: C:\TeamCity\buildAgent\work\f7928b43a423b8ff\src\JCI.ITC.COMP2.Search.IntegrationTests\bin\Release
[14:35:12][Step 6/6]     ImageRuntimeVersion: 4.0.30319
[14:35:12][Step 6/6]     ImageTargetFrameworkName: .NETFramework,Version=v4.7.2
[14:35:12][Step 6/6]     ImageRequiresX86: False
[14:35:12][Step 6/6]     ImageRequiresDefaultAppDomainAssemblyResolver: False
[14:35:12][Step 6/6]     NumberOfTestWorkers: 2
[14:35:12][Step 6/6] 
[14:35:12][Step 6/6] Test Run Summary
[14:35:12][Step 6/6]   Overall result: Warning
[14:35:12][Step 6/6]   Test Count: 13, Passed: 11, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 2
[14:35:12][Step 6/6]     Skipped Tests - Ignored: 2, Explicit: 0, Other: 0
[14:35:12][Step 6/6]   Start time: 2018-08-08 12:33:57Z
[14:35:12][Step 6/6]     End time: 2018-08-08 12:35:12Z
[14:35:12][Step 6/6]     Duration: 75.068 seconds
[14:35:12][Step 6/6] 
[14:35:12][Step 6/6] Results (nunit3) saved as C:\TeamCity\buildAgent\temp\buildTmp\eWgQASs1HMWflTd4lND2sWNURPc3yFDs.nunit.xml
[14:35:12][Step 6/6] 
[14:35:12][Step 6/6] NUnit.Engine.NUnitEngineUnloadException : Multiple exceptions encountered. Retrieve AggregatedExceptions property for more information
[14:35:12][Step 6/6]   ----> NUnit.Engine.NUnitEngineUnloadException : Agent Process was terminated successfully after error.
[14:35:12][Step 6/6]   ----> NUnit.Engine.NUnitEngineUnloadException : Exception encountered unloading application domain
[14:35:12][Step 6/6]   ----> NUnit.Engine.NUnitEngineException : Exception encountered unloading application domain: Error while unloading appdomain. (Exception from HRESULT: 0x80131015)
[14:35:12][Step 6/6] Application domain name: domain-ffefe317-eWgQASs1HMWflTd4lND2sWNURPc3yFDs.nunit
[14:35:12][Step 6/6] Application domain BaseDirectory: C:\TeamCity\buildAgent\work\f7928b43a423b8ff\src\JCI.ITC.COMP2.Search.IntegrationTests\bin\Release\
[14:35:12][Step 6/6] 
[14:35:16][Step 6/6] [JetBrains dotCover] Coverage session finished [08-08-2018 14:35:16]
[14:35:16][Step 6/6] [JetBrains dotCover] Analyzed application exited with code '-5'
[14:35:16][Step 6/6] [JetBrains dotCover] Coverage results post-processing started [08-08-2018 14:35:16]
[14:35:16][Step 6/6] [JetBrains dotCover] Coverage results post-processing finished [08-08-2018 14:35:16]

1 个答案:

答案 0 :(得分:2)

对任何人都应该有帮助-最终我让它起作用了。

也许也曾经是数据库集成测试,但是下面列出了我通过它的最终更改。

StructureMap的IContainer是IDisposposable的,显然,完成测试后,单元测试过程会保留在二进制文件上,从而防止卸载。

之前

        [Test]
    public void ThatControllersCanBeCreatedByIocContainer()
    {
        // Arrange
        var sut = WebIoC.Initialize();

        // Act
        var searchRequestController = sut.GetInstance<SearchRequestController>();
        var searchStatusController = sut.GetInstance<SearchStatusController>();

        // Assert
        Assert.IsNotNull(searchRequestController);
        Assert.IsNotNull(searchStatusController);
    }

之后

        [Test]
    public void ThatControllersCanBeCreatedByIocContainer()
    {
        // Arrange
        using (var sut = WebIoC.Initialize())
        {
            // Act
            var searchRequestController = sut.GetInstance<SearchRequestController>();
            var searchStatusController = sut.GetInstance<SearchStatusController>();

            // Assert
            Assert.IsNotNull(searchRequestController);
            Assert.IsNotNull(searchStatusController);
        }
    }

其中WebIOC.Initialize()看起来像(标准的东西):

    public static class WebIoC {
    public static IContainer Initialize() {
        return new Container(c =>
        {
            c.AddRegistry<WebRegistry>();
            c.AddRegistry<SharedRegistry>();

            c.Scan(scan =>
            {
                scan.TheCallingAssembly();

                scan.WithDefaultConventions();
            });
        });
    }
}