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

Unit tests in nested classes can't be run or debugged #743

Closed
veggerby opened this issue Sep 4, 2016 · 0 comments
Closed

Unit tests in nested classes can't be run or debugged #743

veggerby opened this issue Sep 4, 2016 · 0 comments
Assignees
Milestone

Comments

@veggerby
Copy link

veggerby commented Sep 4, 2016

It is not possible to use a unit test structure like the one suggested by Phil Haack, combined with VS Code 'run test' or 'debug 'test'.

Environment data

dotnet --info output:
.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: 1e9d529bc5

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.11
OS Platform: Darwin
RID: osx.10.11-x64

VS Code version:
C# Extension version: 1.4.1

Steps to reproduce

  1. Add a project.json with the following contents:
{
  "version": "1.0.0-*",
  "dependencies": {
    "xunit": "2.1.0",
    "dotnet-test-xunit": "2.2.0-preview2-build1029",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    }
  },
  "testRunner": "xunit",
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  }
}
  1. Add Test.cs with the following contents:
using Xunit;

namespace TestTest
{
    public class Test
    {
        [Fact]
        public void Should_hit_breakpoint_and_it_does()
        {
            System.Console.WriteLine("Should hit, and it does");
        }

        public class NestedTest
        {
            [Fact]
            public void Should_hit_breakpoint_but_does_not()
            {
                System.Console.WriteLine("Should hit, but does not");
            }
        }
    }
}
  1. Run dotnet restore
  2. Set breakpoint to System.Console.WriteLine in Test.cs
  3. Run "debug test" on both

Expected behavior

Debug test
Both breakpoints are hit

Run test

Running test TestTest.Test.Should_hit_breakpoint_and_it_does...
Test passed

Running test TestTest.Test.NestedTest.Should_hit_breakpoint_but_does_not...
Test passed

Actual behavior

Debug test
Only Should_hit_breakpoint_and_it_does break point is hit, while 'Should_hit_breakpoint_but_does_not' is not

Run test

Running test TestTest.Test.Should_hit_breakpoint_and_it_does...
Test passed

Running test TestTest.Test.NestedTest.Should_hit_breakpoint_but_does_not...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants