nunit/nunit3-vs-adapter

Running Selected Test on Visual Studio Not Working with NUnit Test Adapter

AsifulNobel opened this issue · 5 comments

Hi all, I was trying to run NUnit tests from Visual Studio Test Explorer today by selecting a test. But it kept running all tests of the project instead of the selected one. Same issue persists on debug too.

I was able to workaround it by changing the DiscoveryMethod in .runsettings file to Legacy. I think this is a bug of default DiscoveryMethod.

NUnit Version: 3.0.1
NUnit3TestAdapter: 4.1.0
Visual Studio: 2019 v16.8.1 Community Edition
.NET Target Framework Version: 4.5.1

Have you turned off the Real Time Discovery in Test Explorer ?
Can you upload a small repro project?

PS: Should not affect this, but your NUnit version is a bit behind.

@OsirisTerje I tried with Real Time Discovery option turned on and off. The result was the same.

Yeah, I know about the NUnit version. But unfortunately cannot do much about it at the moment.

I will try uploading a repro project and share the GitHub link here.

@OsirisTerje Here is the public repo link to reproduce the issue - https://github.com/AsifulNobel/nunit3-vs-test-adapter-issue-915.

I also tested with the latest NUnit version on this project and it worked without the issue surprisingly.

Tests were done on Visual Studio 2019 v16.11.6 Community Edition.

Thanks for the repro, I do see the same behavior. But, this is actually caused by the NUnit version. If you update to the latest 3.13.2 version, you will find it works as it should.
image

There are three (actually more, but this holds in this case) components involved, the adapter, the engine - which is embedded with the adapter, and the framework. There is no guarantee that all possible combinations of these works. There is an interesting read on this on Charlies blog. There has also been significant changes between some of the versions here, so seeing this with adapter 4.1 runnings against NUnit 3.0 is not very surprising. That is also the reason for the Legacy discovery method, we did expect that something old could break. You were just one who found one example of that :-)

I would suggest you find a way to upgrade the framework. The version 4 adapter will probably in some time be bound to specific NUnit framework versions. There should be no need to stay on earlier versions of the framework.
Are there any specific reason for staying on version 3.0 ?

@OsirisTerje No, there are no specific reason to stay at version 3.0.1. Thanks for the info on dependency among adapter, engine and framework.