NUnit failed to load test assembly, test doesn't run
See original GitHub issueWhen trying to run a test from Visual Studio, I sometimes see the following output, and the test doesn’t run:
[1/14/2019 1:57:48 PM Informational] ------ Run test started ------
[1/14/2019 1:57:48 PM Informational] NUnit Adapter 3.12.0.0: Test execution started
[1/14/2019 1:57:48 PM Informational] Running all tests in C:\Code\NServiceBus.Persistence.ServiceFabric\src\Tests\bin\Debug\net452\Tests.dll
[1/14/2019 1:57:48 PM Informational] NUnit failed to load C:\Code\NServiceBus.Persistence.ServiceFabric\src\Tests\bin\Debug\net452\Tests.dll
[1/14/2019 1:57:48 PM Informational] NUnit Adapter 3.12.0.0: Test execution complete
[1/14/2019 1:57:48 PM Warning] No test matches the given testcase filter `FullyQualifiedName=ApiApproval.Approve` in C:\Code\NServiceBus.Persistence.ServiceFabric\src\Tests\bin\Debug\net452\Tests.dll
[1/14/2019 1:57:48 PM Informational] ========== Run test finished: 0 run (0:00:00.6869999) ==========
This same test runs fine on my CI server.
Is there any way to get more information about why the test assembly could not be loaded?
NUnit 3.11 NUnit3TestAdapter 3.12.0 VS 2017 15.9.5
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12 (9 by maintainers)
Top Results From Across the Web
c# - NUnit failed to load DLL
delete your bin and obj folder and rebuid it and try to run. · did you check that the file exists and has...
Read more >NUnit failed to load Unit Test Project dll
Typically the problem is caused because the NUnit adapter or framework nuget package is not installed or needs to be update.. Click to...
Read more >Known Problems
Visual Studio 2017 Live Unit Testing require NUnit3. The NUnit2 adapter doesn't support Live Unit Testing. Exception: Could not load file or assembly...
Read more >C# – NUnit failed to load DLL
I am getting the following error message when trying to run unit tests in Visual Studio: NUnit failed to load w:\Repos\trading.tools\Trading.Tools.
Read more >ReSharper test runner fails to run because it can't load nunit ...
ReSharper test runner fails to run because it can't load nunit.core.dll but VS Test Runner works. Hello,. We are having a problem running...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

In my case it was Visual Studio that added and changed some dependentAssembly elements in the App.config of the test project. Undoing these changes made the tests run again.
EDIT: I could repro this by updating NUnit from Nuget. This would add System.Net.Http as a dependentAssempy. Remove this element from app.config makes the tests run again.
Here’s the output I’m seeing:
For this specific repo, that made me realize there is an x86/x64 mismatch. Once I fixed that, the test is running properly!
I have seen this in other repos which I don’t think would have the same architecture mismatch, but now I have a way to dig into why they are failing.
It would be nice if the default test adapter output could surface more detailed error information somehow without needing a runsettings file, though.