nunit / nunit-vs-adapter

Runs NUnit V2 tests inside the Visual Studio 2012 or later Test Explorer window.
MIT License
50 stars 43 forks source link

No Source location for inner (nested) test fixture class #164

Open pkrukp opened 6 years ago

pkrukp commented 6 years ago

Hi,

if inner (nested) class is marked with TestFixture, then there is no information about source code:

 public class OuterClass
    {
        [TestFixture]
        public class InnerClass
        {

The source information is not present at least for parametrized tests, I have not checked normal tests. The lack of source information can be seen in VS Test Explorar, but also when using vstest programmatically through VsTestConsoleWrapper.

Attaching Nested.zip - solution with:

Reproduction steps:

  1. Unpack zip to a folder, for example C:\tmp\Nested
  2. Build solution
  3. Run tests using VS test explorer
    • Notice for "NormalClass" tests there is Source link in details
    • Notice for "InnerClass" tests there is "Source: no source available" text present. This means that for passed tests there is no information about location at all, as stack trace is also not available
  4. Run tests using VsTestConsoleWrapper
    • Download vstest.console.runner (https://www.nuget.org/packages/Microsoft.TestPlatform/15.6.0-preview-20180109-01), unpack to a folder, for example C:\tmp\microsoft.testplatform.15.6.0-preview-20180109-01
    • Run Microsoft.TestPlatform.TranslationLayer.E2ETest.exe with apropriate arguments, for example: "C:\tmp\Nested\Microsoft.TestPlatform.TranslationLayer.E2ETest\bin\Debug\net451\win7-x64\Microsoft.TestPlatform.TranslationLayer.E2ETest.exe" "--runner:C:\tmp\microsoft.testplatform.15.6.0-preview-20180109-01\tools\net451\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" "--testassembly:C:\tmp\Nested\NestedClassTest\bin\Debug\NestedClassTest.dll" "--testadapterpath:C:\tmp\Nested\packages\NUnitTestAdapter.2.1.1\tools\NUnit.VisualStudio.TestAdapter.dll"
    • Notice that TestCase associated with results for "InnerClass" do not have source CodeFilePath and LineNumber

nunit inner class

jnm2 commented 6 years ago

Here is the fix that was done to the current adapter: https://github.com/nunit/nunit3-vs-adapter/pull/285

spencerb02 commented 6 years ago

That pull request was merged in a year ago. Why is this still a problem? We are still setting the issue resolved by #285 when upgrading to 3.9 from 2.6.4 in visual studio 2017. "No source available"

jnm2 commented 6 years ago

@OsirisTerje Should we move this to the nunit3 adapter repo?

pkrukp commented 6 years ago

From my (test adapter user) perspective, if I had problem with test adapter v2, I would search issues in test adapter v2 github project, not v3.

If problem also occurs in test adapter v3 (I think I also tested v3 and I think this problem did not happen for me - I'm not 100% sure) I would prefer to have a separate issue created in the v3 github project.

CharliePoole commented 6 years ago

If it's a problem in the v2 adapter, then it belongs here. If other people have a problem on v3, we may need a separate issue.

jnm2 commented 6 years ago

The reason I asked is that we're doing our best to move people to v3 and the v3 adapter to focus our efforts there rather than publish a new v2 adapter.

CharliePoole commented 6 years ago

Understood. My comment was meant to reflect my disagreement with that policy.