nunit-console: Exception encountered unloading AppDomain
We tested the fix for #168 via the 3.6.1 NuGet release but still get other sporadic failures:
nunit3-console.exe ..... --work=.../Release --out=TestOutput.log --result=TestResult.xml --labels=On --framework=net-4.5 --dispose-runners --agents=8
Unhandled Exception: NUnit.Engine.NUnitEngineException: Exception encountered unloading AppDomain
Agent Process was terminated successfully after error.
at NUnit.Engine.Runners.ProcessRunner.Dispose(Boolean disposing)
at NUnit.Engine.Runners.AbstractTestRunner.Dispose()
at NUnit.Engine.Runners.TestExecutionTask.Execute()
at NUnit.Engine.Runners.ParallelTaskWorkerPool.ProcessTasksProc()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 43 (17 by maintainers)
I have the same issue, after passing all tests, I get
Nunit Version: 3.7.0
The trick here is that the tests have already been run and the result reported before this error actually occurs. Since the problem happens “between” test runs - in the case of the console after the sole test run - there’s no place to report it except in an exception of some kind. So, it comes down to a matter of how the console handles the exception.
NUnitEngineException is used to report errors in the engine, which usually mean the test cannot be run. Perhaps we should not be wrapping this exception but let the console handle the CannotUnloadAppDomainException and just issue a warning.
@Rajkumar-Uppala - thanks for following up. You’re correct this has changed from a warning to an error - as you’ll see above, we’re actually considering changing it back!
In my opinion, it’s important to flag it to the user in a non-ignorable way, so that the user can make some attempt to fix the issue. As you’ve seen - it often highlights a more fundamental issue in user-code. It would be better if we could write the results file out however, and just exit with a non-zero code.
This suggestion of yours is still the best idea imo @CharliePoole. Just needs someone to do a pull request for it… @Fernell or @jgrossrieder, either of you interested? 😄
I’m traveling at the moment but here’s a quick update. I debugged the process on the CI machine and found the culprit in our tests. One of them was holding an active thread that was blocking the unloading.
I think a good option would be to dump the callstacks of all threads of the agent processes before throwing the unload exception. That would help a lot to find what is going on.
Cheers
Le 12 avr. 2017 1:51 AM, “Michael Letterle” notifications@github.com a écrit :
No worries - I’ll see how I get on!
#116 I’m less worried about, nobodies really been chasing that one. I wanted to get a fix in for this issue, as it keeps attracting people at the moment. 😄