question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NUnit failed to load test assembly, test doesn't run

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
gabbsmocommented, Mar 29, 2019

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.

2reactions
bordingcommented, Jan 14, 2019

Here’s the output I’m seeing:

<?xml version="1.0" encoding="utf-8"?>
<NUnitXml>
<test-run id='2' name='Tests.dll' fullname='C:\Code\NServiceBus.Persistence.ServiceFabric\src\Tests\bin\Debug\net452\Tests.dll' testcasecount='0'>
   <test-suite type='Assembly' id='0-1000' name='Tests.dll' fullname='Tests.dll' runstate='NotRunnable' testcasecount='0'>
      <properties>
         <property name='_SKIPREASON' value='Could not load file or assembly &apos;Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b50674d1e0c6ce54&apos; or one of its dependencies. An attempt was made to load a program with an incorrect format.' />
      </properties>
   </test-suite>
</test-run>
</NUnitXml>

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found