Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An exception occurred while invoking executor 'executor://nunit3testexecutor/' #259

Closed
paiden opened this issue Nov 7, 2016 · 3 comments
Milestone

Comments

@paiden
Copy link

paiden commented Nov 7, 2016

When I try to run my tests from Visual Studio, since a few days, I get the error message:

------ Run test started ------
NUnit Adapter 3.0.10.0: Test execution started
Running selected tests in D:\PROJ_DIR\bin\Debug\Testing\Core.UnitTest.dll
An exception occurred while invoking executor 'executor://nunit3testexecutor/': Failed to resolve assembly: 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
========== Run test finished: 0 run (0:00:00.453) ==========

This issue suddenly appeared. At least I cannot remember that I updated something on my system.

The used VS version is 2015 Update 3. I can see the same behavior in VS15 Preview 5.

Any help to diagnose / fix / work around the issue would be appreciated.

Note: This issue doesn't happen in the 3.5.1 version of the test adapter, but as my test currently crash with app domain unload exceptions in that version, I cannot upgrade yet.

@rprouse
Copy link
Member

rprouse commented Nov 7, 2016

I think that if you have installed the test runner as a VSIX, you could find it in C:\Users\{USER}\AppData\Local\Microsoft\VisualStudio\14.0\Extensions and delete the Microsoft.VisualStudio.TestPlatform.ObjectModel.dll.

Ideally you should upgrade by figuring out why you are getting app domain unload exceptions. Can you give us any information on that?

@paiden
Copy link
Author

paiden commented Nov 8, 2016

I forgot to mention, that the adapter is integrated via a NuGet package, so no VSIX extension is installed.
The mentioned file also doesn't exist on my system.

When I Install the NUnit Adapter 3.0.10 Visual Studio Extension, the test will work again.

Regarding the AppDomain unload exception. In that case I think the problem is related to our tests that will take some time to improve (they start threads that are never stopped...).

When I run the tests I get output like this:

System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain. This can happen if the test(s) started a thread but did not stop it. Make sure that all the threads started by the test(s) are stopped before completion.
Exception NUnit.Engine.NUnitEngineException, Exception thrown executing tests
Exception encountered unloading AppDomain
Running all tests in D:\rx\m\Testing\Controls.UnitTest\bin\Debug\Controls.UnitTest.dll
...
NUnit Adapter 3.5.1.0: Test execution complete
========== Run test finished: 1563 run (0:01:23,9897057) ==========

The problem is, that there are more than 3000 tests, so at some random point the execution just stops and doesn't continue, the overall test result will be 'green'. When I debug the tests, none of the app domain unload exceptions is printed, and all the tests execute.

@gimpf
Copy link

gimpf commented May 2, 2017

This issue (edit: about the AppDomain unload) is fixed by PR #318.

The NUnit TestAdapter tries to unload the app-domain after executing the tests, but the CLR fails to do it (for whatever reason, likely some background thread inhibiting shutdown for a bad reason), and throws a CannotUnloadAppDomainException, resulting in the messsage "Exception encountered unloading AppDomain".

When running only selected tests, this cancels any further test execution (when running all tests, this exception is only logged and other tests continue execution).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants