nunit-vs-adapter icon indicating copy to clipboard operation
nunit-vs-adapter copied to clipboard

No Source location for inner (nested) test fixture class

Open pkrukp opened this issue 7 years ago • 7 comments

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:

  • NestestClassTest project which contains tests cases for "normal" and "nested" class
  • Microsoft.TestPlatform.TranslationLayer.E2ETest which provides program executable which uses VsTestConsoleWrapper and shows displays TestResults/TestCases returned

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

pkrukp avatar Jan 17 '18 12:01 pkrukp

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

jnm2 avatar Jan 18 '18 13:01 jnm2

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"

spencerb02 avatar Feb 06 '18 15:02 spencerb02

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

jnm2 avatar Feb 07 '18 23:02 jnm2

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.

pkrukp avatar Feb 08 '18 08:02 pkrukp

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.

CharliePoole avatar Feb 08 '18 11:02 CharliePoole

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.

jnm2 avatar Feb 08 '18 12:02 jnm2

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

CharliePoole avatar Feb 08 '18 14:02 CharliePoole