NUnit.Engine.NUnitEngineUnloadException : Multiple exceptions encountered. Retrieve AggregatedExceptions property for more information

3

When running my tests on build server TeamCity, I get [subject] in my log and step fails.

The code was result of a rather large inclusion of code that makes it hard to pinpoint excactly what I'm doing wrong (and I'd rather not roll back changes and do it again in small steps).

How can I fix this? How can I pinpoint what the problem is?

I'm running - nunit nuget 3.10.1 (latest official at the time of writing) - nunit.console 3.8.0 on build server with x64/v4.0

Running locally (through R#) on my dev machine, I see no problems.

The tests are database-based tests where I create a new database for the test (case) and then removes it when test is done.

Any suggestions welcomed!

BR - Anders

[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]
nunit
asked on Stack Overflow Aug 8, 2018 by Anders Juul

1 Answer

3

Should it help anyone -- In the end I got it to work.

It might have been the database integration tests also, but the final change where I got it to pass is listed below.

StructureMap's IContainer is IDisposable and apparently the unit test process held on to the binaries after completing the test thus preventing unload.

Before

[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);
}

After

[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);
    }
}

where WebIOC.Initialize() look like (standard stuff):

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();
            });
        });
    }
}
answered on Stack Overflow Aug 9, 2018 by Anders Juul • edited Jul 4, 2019 by Ondrej

User contributions licensed under CC BY-SA 3.0