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

Test Case Source us not available when using SetName

Open MattKeenum opened this issue 5 years ago • 11 comments

NUnit: v3.12.0 NUnit3TestAdapter: v3.16.1 VS Edition: Professional 2019 VS Version: 16.4.4

This issue is probably related to Visual Studio rather than NUnit, but I thought you guys might have some insight.

Issue: When using SetName and creating custom test cases, the source is no longer available in the Test Explorer.

In a previous version of VS 2019, this was not the case. Test Cases created with SetName still had the original source (even when the Test Case was duplicated). This allowed the end user to double-click the custom Test Case and it would take them to the appropriate test method. In a recent update to VS 2019, the Test Explorer got an overhaul, and that is when this issue started happening.

The same issue happened In VS 2017. However, there was an extension installed and enabled by default: Dotnet Extension for Test Explorer. We could disable this extension and all of the custom test cases would then have a source attached to them. We could double-click a custom test case and it would take us to the test method. This extension is no longer showing in the Manage Extensions for VS 2019.

VS 2019 1581087780825_image001

VS 2017 1581087791493_image002

MattKeenum avatar Feb 07 '20 15:02 MattKeenum

Yes, this is one of the issues we're struggling with now. There is an alignment issue between the way the Test Explorer now works, and the adapter.
For your case, you can try to use the two settings https://github.com/nunit/docs/wiki/Tips-And-Tricks#useparentfqnforparametrizedtests and https://github.com/nunit/docs/wiki/Tips-And-Tricks#usenunitidfortestcaseid and set both to true. If may 1) work or 2) crash or not run, depending upon your tests. So YMMV.

And yes, we're working on getting these things fixed.

OsirisTerje avatar Feb 07 '20 15:02 OsirisTerje

Hi,

I also faced the same issue and followed the setting that you have mentioned above. Added below lines in Run settings XML file.

true true

I can get the source information but I am facing a different issue.

I am having multiple sets of data under one test method. For each data, I am naming different using SetName.

Now I am trying to run specific data from test explore but it runs all the data for the test method. Also, the spinner icon is not coming for the tests in the test explorer.

Kindly help me with this.

IbbuGit avatar May 11 '20 19:05 IbbuGit

@IbbuGit When you turn on those settings, the effect is that the parent is being run, not the children. So what you see is what is expected in that case.

OsirisTerje avatar May 11 '20 20:05 OsirisTerje

Oh ok. Is there any way I can run a specific child under the parent?

IbbuGit avatar May 11 '20 21:05 IbbuGit

What happens if you dont turn those two settings on ? With them off, you can run the testcases individually. Thats the difference between those two.

OsirisTerje avatar May 11 '20 22:05 OsirisTerje

I am getting a source not available issue for each child(data) under the parent(test method) but able to execute a specific child under the parent.

IbbuGit avatar May 11 '20 22:05 IbbuGit

Do we have any solution like I should not get source not available issues and I should be able to run the test case individually? Currently I am using this
UseParentFQNForParametrizedTests-true UseNUnitIdforTestCaseId-true With this I am not facing source not available issue but not able to execute test individually.

IbbuGit avatar May 12 '20 18:05 IbbuGit

  1. This is part of the issue mentioned in 2nd comment above.
  2. Using the mentioned properties set to true, will make running by children of the method parent not possible. That's kind of the result of that fix, and also how Test Explorer expects this.

You should test without these properties, BUT turn off RTD (Real time discovery)(see Options/Test). That way NUnit will handle the discovery and not Test Explorer, and it is more likely to hit correct. I do believe this should fix your issue though.
image

( Also, without knowing anything more about your specific source (no repro), I am just assuming how you have your code. )

OsirisTerje avatar May 12 '20 19:05 OsirisTerje

I am getting below issue now

A source not available issue for each child(data) under the parent(test method) but able to execute a specific child under the parent.

IbbuGit avatar May 12 '20 23:05 IbbuGit

Any updates on this bug?

IbbuGit avatar Jun 03 '20 20:06 IbbuGit

Sorry, still waiting for MS

OsirisTerje avatar Jul 08 '20 15:07 OsirisTerje