nunit3-vs-adapter
nunit3-vs-adapter copied to clipboard
Run/Debug tests in context doesn't work correctly with generic fixtures
@martynsmall commented on Tue Aug 12 2014
If you have a generic fixture and try running or debugging a single test by right clicking it in code and selecting 'Run Tests' or 'Debug Tests' it instead runs all tests in the code file. Doing the same for a non generic fixture correctly runs just the single test.
Referring to the example below, the tests NonGenericTest1 and NonGenericTest2 can be run independently, but attempting to run either GenericTest1 or GenericTest2 results in all four being run. Ideally it should run just the selected test for each of the generic types specified.
[TestFixture(typeof(int))]
public class GenericTests<T>
{
[Test]
public void GenericTest1()
{
}
[Test]
public void GenericTest2()
{
}
}
[TestFixture]
public class NonGenericTests
{
[Test]
public void NonGenericTest1()
{
}
[Test]
public void NonGenericTest2()
{
}
}
@OsirisTerje commented on Mon Sep 01 2014
I can't repro this with the adapter version 1.1.0.8, using VS 2013 Update 3. I haven't checked earlier versions. Can you give some more details on your setup ?
@martynsmall commented on Mon Sep 01 2014
I'm experiencing this on all three machines I've tried - two running VS 2013 Update 3 using version 1.1.0.0 of the adapter and one using VS 2012 with 1.1.0.8 of the adapter. I can reproduce it simply by creating a new solution (class library), adding in a reference to NUnit through NuGet and pasting in the above code over Class1. Right clicking on the method name of either of the generic tests in the code window and selecting 'Run Tests' runs all 4 of them. They can be run independently from the test explorer, it's only a problem when run from the code window.
@CharliePoole commented on Mon Sep 01 2014
To run from the code window, VS has to deduce the NUnit tests from the code location. The only info it has available is the class and method representing the test, which the adapter gives it during discovery.
Rob, you could check exactly what we pass it during discovery in this situation.
Charlie
On Mon, Sep 1, 2014 at 2:59 PM, martynsmall [email protected] wrote:
I'm experiencing this on all three machines I've tried - two running VS 2013 Update 3 using version 1.1.0.0 of the adapter and one using VS 2012 with 1.1.0.8 of the adapter. I can reproduce it simply by creating a new solution (class library), adding in a reference to NUnit through NuGet and pasting in the above code over Class1. Right clicking on the method name of either of the generic tests in the code window and selecting 'Run Tests' runs all 4 of them. They can be run independently from the test explorer, it's only a problem when run from the code window.
— Reply to this email directly or view it on GitHub https://github.com/nunit/nunit-vs-adapter/issues/43#issuecomment-54093980 .
@CharliePoole commented on Tue Dec 01 2015
Looks like nobody followed up on my Sep 1 question
@CharliePoole commented on Tue Dec 01 2015
@OsirisTerje This seems like something we would either fix in both or close if we can't confirm it.
I can confirm this, I noticed it while testing base class issues.
One thing I've noticed is that the tests in abstract or generic base classes do not have the test CodeLens.

vs

I am experiencing this same problem with Visual Studio 2017 and Nunit3 Test Adapter 4.2.1. I haven't been able to determine the exact circumstances that makes this issue happen, but it has happened to me repeatedly. Usually it occurs if I right-click on a test method and select Debug Test(s) from the context menu. Seems like if I do a rebuild it work will work again. Other times, I need to completely exit Visual Studio 2017 and start it again for it to work.