nunit3-vs-adapter: Fail to run tests in VS2017 15.6

With NUnit 3.9 and the TestAdapter v3.9 the execution of tests within VisualStudio does not work anymore.

[07.03.2018 08:22:48 Informational] ------ Load Playlist started ------
[07.03.2018 08:22:48 Informational] ========== Load Playlist finished (0:00:00,0320021) ==========
[07.03.2018 08:26:05 Informational] ------ Run test started ------
[07.03.2018 08:26:07 Informational] NUnit Adapter 3.9.0.0: Test execution started
[07.03.2018 08:26:07 Informational] Running all tests in C:\Data\GIT\IdentityProvider\tests\CHG.IdentityServer.Tests\bin\Debug\net461\win7-x86\CHG.IdentityServer.Tests.dll
[07.03.2018 08:26:08 Warning] Exception System.InvalidOperationException, Exception thrown executing tests in C:\Data\GIT\IdentityProvider\tests\CHG.IdentityServer.Tests\bin\Debug\net461\win7-x86\CHG.IdentityServer.Tests.dll
[07.03.2018 08:26:08 Warning] Operation is not valid due to the current state of the object.
[07.03.2018 08:26:08 Warning]    at Mono.Cecil.ModuleDefinition.ProcessDebugHeader()
   at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader)
   at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
   at Mono.Cecil.ModuleReader.CreateModuleFrom(Image image, ReaderParameters parameters)
   at Mono.Cecil.ModuleDefinition.ReadModule(Stream stream, ReaderParameters parameters)
   at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
   at NUnit.VisualStudio.TestAdapter.NavigationDataProvider.CacheNewTypes(String assemblyPath, IDictionary`2 types) in C:\Users\Terje\Source\Repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\NavigationDataProvider.cs:line 103
   at NUnit.VisualStudio.TestAdapter.NavigationDataProvider.GetNavigationData(String className, String methodName) in C:\Users\Terje\Source\Repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\NavigationDataProvider.cs:line 48
   at NUnit.VisualStudio.TestAdapter.TestConverter.MakeTestCaseFromXmlNode(XmlNode testNode) in C:\Users\Terje\Source\Repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\TestConverter.cs:line 144
   at NUnit.VisualStudio.TestAdapter.TestConverter.ConvertTestCase(XmlNode testNode) in C:\Users\Terje\Source\Repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\TestConverter.cs:line 79
   at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunAssembly(String assemblyPath, TestFilter filter) in C:\Users\Terje\Source\Repos\nunit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestExecutor.cs:line 249
[07.03.2018 08:26:08 Informational] NUnit Adapter 3.9.0.0: Test execution complete
[07.03.2018 08:26:08 Warning] No test is available in C:\Data\GIT\IdentityProvider\tests\CHG.IdentityServer.Tests\bin\Debug\net461\win7-x86\CHG.IdentityServer.Tests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[07.03.2018 08:26:08 Informational] ========== Run test finished: 0 run (0:00:03,1841635) ==========

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 35 (13 by maintainers)

Most upvoted comments

Confirmed, the real issue I had is assembly version mismatch. We use some legacy classic .NET libraries, and target .NET Core 1.1 in our projects. But Tests.Common contained App.config with the following binding redirects

      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>

There was no build errors or warningns, but NUnit Adapter was unable to discover tests there. Having in mind this open issue https://github.com/nunit/nunit3-vs-adapter/issues/489 all becomes explainable. After setting redirect to 1.1.1.0 tests got discovered and everything works as expected.

@OsirisTerje thank you for paying attention.

I had the same issue. for me it was resolved by adding some package references in the csproj file.

I found this thanks to the link posted by Terje (look at section 2.3) :
http://hermit.no/how-to-resolve-cases-of-visual-studio-no-tests-appearing/

Hi Osiris

Thank you for your reply. Truthfully i am almost at the “give up” point… 😦

Here the answers for each question:

Which version of the adapter and NUnit itself are you using?

  • VS Nuget Package for Nunit: v.3.10.1 - VS Nuget Package for Nunit3TestAdapter: v.3.10.0 What VS version do you see this in?
  • VS 2017 Enterprise What kind of test project (.net FW, or .net core ) do you see this in?
  • .net FW Do you have any repro you could share?
  • Not sure what it means, but if needed i can zip and send solution

Note - i am very new to this. I was learning and making a good progress on my own (from internet). at my work i came across these Tests that were written in VS 2013 and Nunit 2.x. So first they were not showing in the Test Explorer. Now i made them show but have this message and basically not running anymore.

Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.

And now my previously written solution i was learning with and developed on my own - also not working with the similar issue.

Thank you very much! Andrew