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

Fatal error debugging tests via Test-Explorer #320

Closed
bunnu opened this issue May 4, 2017 · 29 comments
Closed

Fatal error debugging tests via Test-Explorer #320

bunnu opened this issue May 4, 2017 · 29 comments
Labels
closed:SomebodyElsesProblem Closed because there is nothing we can do, as this is caused by an external component External Tracked here, but must be fixed in external tool is:bug VS Issue

Comments

@bunnu
Copy link

bunnu commented May 4, 2017

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" />
@bunnu bunnu changed the title Fatal error debugging Tests via Test-Explorer Fatal error debugging tests via Test-Explorer May 4, 2017
@mikebeaton
Copy link

(FWIW I can debug individual tests with 3.8-alpha in my setup, so this problem is not universal. I don't know if it is relevant, but I am not using Moq, and I have VS Professional 2017 15.0.0+26228.9.)

@rprouse
Copy link
Member

rprouse commented May 5, 2017

Debugging is one of the main tests before releasing, so it is definately not universal.

We need to identify what is different about your project or setup so that we can fix this 👍

@rprouse rprouse added confirm We need a separate confirmation of this issue is:bug labels May 5, 2017
@bunnu
Copy link
Author

bunnu commented May 5, 2017

Hi Rob,

I'm little bit confused: The solution, which was generating the mentioned fatal error yesterday, is working today. I'm quite sure I didn't change anything (code, extensions, packages, etc.). My co-worker had the same issue yesterday. Today it is working too?! I'm also able to debug all your tests in the NUnitPlatformTests-Solution.

Currently I'm not able to reproduce the error.

@rprouse
Copy link
Member

rprouse commented May 5, 2017

@bunnu don't you love working with .NET Core? Thanks for letting me know. I am going to keep this issue open for a bit so others can confirm if it is an issue or not. Maybe it just required a restart of Visual Studio? I do

@Gerfaut can you let us know if it is working for you yet? If not, can you answer any of my questions that I posted above?

@bunnu
Copy link
Author

bunnu commented May 5, 2017

My first try yesterday was restarting Visual Studio, but it didn't solved the problem. Maybe the antivirus caused the issue? I'm using Kaspersky Endpoint Security 10. @Gerfaut which AV are you using?

@ghost
Copy link

ghost commented May 5, 2017

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!

@rprouse
Copy link
Member

rprouse commented May 5, 2017

@Gerfaut thanks for the detailed report. My guess is that it is a Visual Studio or .NET Core tooling bug, but I am going to leave this open to confirm. Personally, Visual Studio 2017 is very buggy working with .NET Core. It often crashes or exhibits weird behaviour whenever I edit the CSPROJ files, so it could be related.

For your other comments, the Service tag is added to all test project by Visual Studio. It is intended to speed up test discovery. The nunit_random_seed.tmp file allows for repeatable test runs when using NUnit's random features. It can be ignored.

@ghost
Copy link

ghost commented May 6, 2017

Hi @rprouse,
Thanks for explanation! If I succeed to find more information, I'll complete it here.
Anyway, you should be right about the VS2017 / .NET Core Tooling bug.
Let's see!

Thanks a lot!!

@NightOwl888
Copy link

NightOwl888 commented May 7, 2017

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.

@rprouse
Copy link
Member

rprouse commented May 7, 2017

@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.

@ircnelson
Copy link

ircnelson commented May 23, 2017

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

@giggio
Copy link

giggio commented Jun 6, 2017

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

@OsirisTerje
Copy link
Member

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!

@OsirisTerje OsirisTerje added VS Issue and removed confirm We need a separate confirmation of this issue labels Jun 25, 2017
@OsirisTerje
Copy link
Member

FWIW: Sometimes I manage to get into some sort of fallback property pages dialog (right clicking the csproj - but only now and then, not sure what is triggering this), and inside that one I can set the Debug Target (to the csproj to debug), and then it all works. I can't yet find that value stored anywhere however, but if anyone have any clues to this:
image

@Delpak
Copy link

Delpak commented Oct 25, 2017

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

@zhenyu-siama
Copy link

zhenyu-siama commented Oct 29, 2017

I had extactly the same issue. Not with NUnit, but XUnit. (So it is a Visual Studio issue, not NUnit issue!)

It was all good last Friday (2017-10-27). This morning (2017-10-30), it crashes whenever I start a debug from test explorer. I could not fix it by restarting Visual Studio or restarting windows.

I did the rebuild as suggested by Delpak, it worked. The error is gone. So try clean & rebuild. Good luck!

@OsirisTerje
Copy link
Member

@navin22 says this is probably related to microsoft/vstest#558

@joost-morsink
Copy link

For me, removing the <Service Include="{GUID}"... solved the problem, at least temporarily.

@k-s-s
Copy link

k-s-s commented Mar 9, 2018

Had this issue with latest VS 15.6.1
Solved with setting test projecct (Class Library) startup object to NUnit.Program, run a test (fails), then revert the setting back to Not Set

@jnm2
Copy link
Contributor

jnm2 commented Mar 20, 2018

@TheCodechimp
Copy link

TheCodechimp commented Apr 12, 2018

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>

@shargon
Copy link

shargon commented Apr 17, 2018

I have the same issue :(

MY SOLUTION

I had a wrong workingDirectory in launchsettings.json

{
  "profiles": {
    "NeoVM.Interop.Tests": {
      "commandName": "Project",
      "workingDirectory": "C:\\Sources\\Neo\\neo-hypervm\\tests\\NeoVM.Interop.Tests\\bin\\Debug\\netcoreapp2.0",
      "nativeDebugging": true
    }
  }
}

@prudhviraj299
Copy link

Cleaning Project resolved my issue.
If this doesn't work restart VS and then clean project before debugging.

@OsirisTerje OsirisTerje added External Tracked here, but must be fixed in external tool closed:SomebodyElsesProblem Closed because there is nothing we can do, as this is caused by an external component labels Aug 9, 2018
@OsirisTerje
Copy link
Member

Close this for now, as there is nothing we can do. Feel free to add links to work-arounds.

@aleha84
Copy link

aleha84 commented Sep 17, 2018

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.

@OsirisTerje
Copy link
Member

@aleha84 That project uses an outdated project format. Create a new project and check if it works for you. You can clone and check this one: https://github.com/OsirisTerje/DotNetCoreTestExample

@VictorioBerra
Copy link

@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.

@freerider7777
Copy link

I had this issue with VS 2017, Nunit3
My test project had in Build -> Platform target x64. I switched to Any CPU and everything is ok :)

@adamsproul
Copy link

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

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed:SomebodyElsesProblem Closed because there is nothing we can do, as this is caused by an external component External Tracked here, but must be fixed in external tool is:bug VS Issue
Projects
None yet
Development

No branches or pull requests