-
Notifications
You must be signed in to change notification settings - Fork 682
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
XUnit projects cannot be launched under the debugger #1292
Comments
@aggieben I think the issue here is that XUnit projects aren't runnable in this way -- it either doesn't run your tests at all, or it runs them in a child process. You can confirm or Deny this theory by adding a Console.WriteLine to one of your tests to see if it runs. If it does run have it print its process id and then pause (ex: |
I should say, in theory the right way to debug a test is to use the little button next to the test method. But from #1100 I gather that that is currently broken for .csproj-based projects. |
@gregg-miskelly indeed, the test launch links decorating the methods do not work for me. If I click |
also doesnt work for me: <ItemGroup>
<PackageReference Include="xunit" Version="2.3.0-beta2-build3683" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta2-build3683" />
</ItemGroup> debugger doesnt hit breakpoints when xunit-cli tool is added works again when commenting out from csproj, removing bin/ and obj/ folder and restoring full csproj
I also tryed to reinstall omnisharp, c# extension and dotnet core |
@jflepp I might suggest opening a new issue. But either way, a few questions:
|
@gregg-miskelly I created a new issue: #1630 |
I'm having similar problems with the new .NET 2.0 (I never tried with earlier SDKs). I had no launch.json and so VS Code created a new one for me but I see the same thing where tests aren't run, the program just exits. Is there something special I need to initiate the running of tests? My repo is public if you want to test: https://github.com/kamranayub/GiantBomb-CSharp/tree/net20 I'll edit/update if I end up figuring it out, I wish it wasn't so hard 😢 |
The fact that you can F5 an xUnit project is really a bit strange. To be honest, C# for VS Code really shouldn't offer to create a launch.json file for them, but xUnit projects are created as "netcoreapp2.0" with no entry point. The trick to debugging unit tests is to open a file containing unit tests and then click the "debug test" annotation above the method: |
Yeah but that still doesn't work with whatever I have set up :( You can
clone my net20 branch and see that too.
…On Fri, Aug 18, 2017 at 10:16 AM Dustin Campbell ***@***.***> wrote:
The fact that you can F5 an xUnit project is really a bit strange. To be
honest, C# for VS Code really shouldn't offer to create a launch.json file
for them, but xUnit projects are created as "netcoreapp2.0" with no entry
point.
The trick to debugging unit tests is to open a file containing unit tests
and then click the "debug test" annotation above the method:
[image: image]
<https://user-images.githubusercontent.com/116161/29465232-71edbe00-83ed-11e7-9fd0-0ccc66b462c0.png>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1292 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAiaa9rVqyps7d-NSf0faC4lIgn2pGqNks5sZarUgaJpZM4MVA2F>
.
|
Here's what I see with your branch:
Is that the same thing you're seeing? |
FWIW, I think this is a completely different problem than what this issue is tracking. |
Yes but I already figured the
I am not sure if it's by design to not work but I'm looking for the same experience I get in Visual Studio 2017 where debugging tests by launching the debugger does work. |
As I mentioned earlier, I wouldn't expect that to work and its somewhat of a bug that we create a launch.json at all for xUnit test projects. Pressing F5 on test project is akin to launching it with 'dotnet run'. It doesn't launch it with the test framework. |
FWIW, the issue I'm seeing looks like it might be a bug introduced in xUnit. If I use the version of xUnit that |
@DustinCampbell Interesting! I just followed the latest docs of xunit, I'll try the earlier version maybe... it said the latest beta 4 adds .NET Core 2.0 support. |
The latest beta 4 definitely should be much better. IIRC, it fixes issues with running tests in VS. I'm debugging this now to see if I can figure out where the issue might be. |
Here's the exception that's happening:
|
The issue appears to be right here: /// <summary>
/// Validates the runtime target framework from test platform with the current adapter's target.
/// </summary>
/// <returns>True if the target frameworks match.</returns>
static bool ValidateRuntimeFramework()
{
#if NETCOREAPP1_0
var targetFrameworkVersion = RunSettingsHelper.TargetFrameworkVersion;
return targetFrameworkVersion.StartsWith(".NETCore", StringComparison.OrdinalIgnoreCase) ||
targetFrameworkVersion.StartsWith("FrameworkCore", StringComparison.OrdinalIgnoreCase);
#else
return true;
#endif
} The problem is that our test runner passes RunSettings to the |
Yup, that's the issue. If I change OmniSharp to pass a run settings file containing |
@DustinCampbell Great, thanks! |
Any idea when the fix will go live. Unless I've misunderstood it's currently impossible to debug either xunit or mstest test which is a major showstopper. |
Not yet, but there is a beta release that you can use in the meantime: 1.13.0-beta3. You can use the instructions here to install a beta release. |
Awesome, thanks Dustin. I've also just worked out that I can run an xunit test, but I just have to enable this horrid codelens thing. Looking forward to the time I can turn that back off. |
Closing stale issue |
The symptoms are related to those described in #1253, but wasn't solved with the thing the closed that one. Environment info is the same.
@gregg-miskelly:
Yes, the issue is 100% repeatable. In this case, the problem is with an Xunit project, called
Saddleback.AspNetCore.Features.Test
. The project file as as follows:The launch.json:
the console output:
and the debug console output:
The text was updated successfully, but these errors were encountered: