nunit3-vs-adapter: Fatal error debugging tests via Test-Explorer

Thanks for your work getting nunit3-vs-adapter running with .net core. Running tests via dotnet test or Test-Explorer in VS seems to work fine.

When i try to debug a test via Test-Explorer a Message-Box with following Message appears:

A fatal error has occurred and debugging needs to be terminated. For more details, please see the Microsoft Help and Support web site. HRESULT=0x8000ffff. ErrorCode=0x0

debug_error

I’m using VS 2017 V15.1 (26403.79) and referencing following packages:

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Moq" Version="4.7.9" />
<PackageReference Include="NUnit" Version="3.6.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0-alpha1" />

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 8
  • Comments: 29 (10 by maintainers)

Most upvoted comments

I had exactly the same problem. But after clean and rebuild the solution, the problem was solved.

VS 2017 Pro. Version: 15.8.4 Still reproducing. Using NUnit 3.10.1. Used solution from here

In my case with Visual Studio 2017 release version the unit test project failed with this error because for some reason the unit test project had a launchsettings.json file under the project “properties” folder. Deleting it resolved the debugging issue.

@aleha84 Thank you!

My issues was my test projects had a launchsettings!

This is because before the fixes in 2.2 we were told for our tests, we need to target the .Web SDK. So as I converted everything over back to the normal SDK those files remained.

Removing the IIS Express profile from the launchsettings.json fixed this issue for me.

image

I apologize if someone already mentioned this, but I encountered this error while trying to debug some Azure functions. You can run into this error if you specify a .NET framework version but have the function API specified to V2. <PropertyGroup> <TargetFramework>net461</TargetFramework> <AzureFunctionsVersion>v2</AzureFunctionsVersion> <== This will cause it to throw the error. Fix is to just change it to V1 </PropertyGroup>

I had the same problem with xUnit and solved this problem changing project type from Library to Console Application:

<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp1.1|AnyCPU'">
  <OutputType>exe</OutputType>
</PropertyGroup>

<PropertyGroup>
  <TargetFrameworks>netcoreapp1.1;net461</TargetFrameworks>
  <AssemblyName>MyProject.UnitTests</AssemblyName>
  <ApplicationIcon />
  <OutputTypeEx>exe</OutputTypeEx>
  <StartupObject />
</PropertyGroup>

My final csproj: https://gist.github.com/ircnelson/9cbddb681d520d7f581dbfc99709a9e1

I had the same problem. Here is my project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
    <PackageReference Include="NUnit" Version="3.6.1" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.8.0-alpha1" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\TestNUnit\TestNUnit.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
  </ItemGroup>

</Project>

It kept producing the same error message as above as many times as I ran it. Then I read some of the posts here that said “overnight it stopped happening”. I decided to close Visual Studio 2017 and reopen it and then it started working. So, it looks like this probably isn’t a problem with the test adapter, but a caching issue of some sort in Visual Studio.

Following @Gerfaut 's recipe (Thanks, that was to the point!!!) , and updating to NUnit 3.7.1, and adapter 3.8.0-alpha1 I can confirm it still fails.

image

I am pretty sure this is VS, so I’ll contact them about it. It might be related to the adapter, that we’re not acting the way we should (but don’t know yet - A little bit of Kafka here), so I’ll keep it open.

PS: Thanks also to @giggio , @ircnelson , @MikeBeaton , @NightOwl888 and @bunnu for the feedback, it really helps when more can confirm and elaborate on the issues!

I can confirm that changing from Library to Console App solves the problem.

@NightOwl888 thanks for the update. It is definately looking like a Visual Studio issue, but I am going to leave this issue open for a bit so others can find it easily.

Hi @rprouse,

I have the exact same behavior than @bunnu, my previous try is now working… but I succeed to recreate the problem. Here are the step to do it:

  • Inside a folder, dotnet new sln
  • Open the sln with Visual Studio 2017
  • From Visual Studio, create a new Class Lib project.
  • Edit the .csproj to add the dependencies (so I am not using Nuget). The csproj is then the following:
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
    <PackageReference Include="NUnit" Version="3.6.1" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.8.0-alpha1" />
  </ItemGroup>

</Project>
  • When I build the solution, those lines are added in the csproj:
<ItemGroup> 
    <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> 
  </ItemGroup> 
  • I try to launch one dummy test and it crashes with the error above.
  • When I close and relaunch Visual Studio, I can debug the test without error. The only file that changed is the Test.NETCoreNunit\ClassLibrary1\bin\Debug\netcoreapp1.1\nunit_random_seed.tmp which was “1972429476” and now contains “971211234” (tracked with GIT).

My AV is BitDefender Endpoint Security Tools but I don’t think there is a issue with this 😃

Does it help a bit ? Do you need the full project (which should work then) ?

Thanks!