nunit / dotnet-test-nunit

Deprecated test runner for .NET Core. For use with project.json only. For recent releases of .NET Core, use the NUnit 3 Visual Studio Adapter
https://www.nuget.org/packages/dotnet-test-nunit/
MIT License
67 stars 25 forks source link

Stack trace has no source links #60

Open BalassaMarton opened 8 years ago

BalassaMarton commented 8 years ago

This works with the classic .NET Framework version as expected: when a test fails, the stack trace contains clickable links to specific source code locations. However, when running tests on a .NET Core test project, there are no links, only string descriptions of the location of the error.

Steps to reproduce

1) Create Class Library (.NET Core) project containing a single class Class1:

    public class Class1
    {
        public void Batman()
        {
            throw new Exception("Batman failed");
        }
    }

2) Create another class library with test class TestClass1:

    [TestFixture]
    public class TestClass1
    {
        [Test]
        public void Test1()
        {
            var obj = new Class1();
            obj.Batman();
            Assert.True(true);
        }
    }

3) Run or debug the test. The test will fail, but the stack trace is not clickable.

image

rprouse commented 8 years ago

Thanks for the detailed report. We will need to confirm that this is an NUnit issue and not a Visual Studio issue. I am pretty sure it is the later since the code for both is the same.

BalassaMarton commented 8 years ago

The weirdest thing is that the link works when the exception is at the top of the stack (eg. an assertion failed).

rprouse commented 8 years ago

One way that we will be able to confirm if this is an NUnit or Visual Studio issue is to try it using xUnit or MSTests.

jcansdale commented 8 years ago

@rprouse Have you ever managed to get 'dotnet-test-mstest' working? It seems to be broken whenever I've tried it. I just assumed they haven't updated it yet for .NET Core 1.0.

BalassaMarton commented 8 years ago

@rprouse I've repeated the steps with Xunit and the stack trace links are working. I believe it is a NUnit-related issue.

CharliePoole commented 8 years ago

NUnit provides a raw stack trace coming from .NET. It isn't reformatted to be clickable. That would be the job of the gui component that formats it for display. I assume that's the adapter in this case.

jcansdale commented 8 years ago

@BalassaMarton Could you try running the same test using TestDriven.Net. Right-click and 'Run Test(s)' inside the test method and double-click on the stack trace in the output window. You can find a preview build here: https://github.com/jcansdale/TestDriven.Net-Issues/issues/21#issuecomment-236192432

As @CharliePoole mentions, it's tools that reformat the message to make them clickable or add hyperlinks. They will expect the stacktrace to be in the default format.

Let me know if this works.

rprouse commented 7 years ago

I have confirmed this to be the case in the NUnit .NET Core runner. It does not happen in MSTest or in xUnit. The .NET Core runner works correctly if the exception is thrown in the test method, just not in a called method.

rprouse commented 7 years ago

I have also confirmed that this works in the full framework NUnit Adapter, so it is definately a .NET Core Adapter issue.