Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUnit Test Discoverer 3 in MS VisStudio 2015 gets a null object reference error when discovering #769

Closed
john-sc opened this issue Jul 15, 2020 · 14 comments
Labels
confirm We need a separate confirmation of this issue

Comments

@john-sc
Copy link

john-sc commented Jul 15, 2020

Using MS Visual Studio Professional 2015
Visual c# 2015
Nunit version 3.12.0
Nunit3 version 3.15.1

I open a solution and it works. Tests are discovered.
I make any change to a line of code and rebuild.
I get
An exception occurred while test discoverer 'NUnit3TestDiscoverer' was loading tests. Exception: Object reference not set to an instance of an object.

@mikkelbu mikkelbu transferred this issue from nunit/nunit-vs-adapter Jul 15, 2020
@mikkelbu
Copy link
Member

@john-sc I'm transferring this issue to the nunit3-vs-adapter repo (the original repo is for the NUnit 2 adaper).

@OsirisTerje
Copy link
Member

@john-sc What happens if you upgrade to 3.17 ?
If it is still there, can you upload a small repro?

@OsirisTerje OsirisTerje added the confirm We need a separate confirmation of this issue label Jul 15, 2020
@john-sc
Copy link
Author

john-sc commented Jul 16, 2020 via email

@prithvivinayak1
Copy link

prithvivinayak1 commented Jul 20, 2020

I have same problem. please help

@justcode411
Copy link

justcode411 commented Jul 20, 2020

I have the same issue, it is extremely frustrating.
NUnit 3.12
NUnitAdapter 3.17
VS 2015 Enterprise
The only way to get it working once the error happens is to restart the compiler. And for large enterprise level apps, it can take 3-4 minutes to reload the solution and you need to do this every time you recompile a small code change if you want to test it.

@OsirisTerje
Copy link
Member

@prithvivinayak1 @justcode411 John-sc solved #769 (comment) his problem by ensuring he didn't have any VSIX based adapters installed at the same time. Can you check the same?

If not, please upload a small repro.

Also, please set Verbosity to 5 (in a runsettings file), and enable the DumpXmlTestDiscovery.

@prithvivinayak1
Copy link

Using MS Visual Studio Professional 2015
Visual c# 2015
Nunit version 3.12.0
Nunit3 version 3.16
.Net framework 4.5.2
I opened a solution and it works. Tests are discovered.
I made some changes to a line of code and rebuild.
I got
An exception occurred while test discoverer 'NUnit3TestDiscoverer' was loading tests. Exception: Object reference not set to an instance of an object.
If i change default processor architecture(Test->Test settings ) from x86 to x64 or x64 to x86 it will work once. Same error occurs during the next rebuild
Annotation 2020-07-20 151745

@prithvivinayak1
Copy link

Hi Thank you. I found my issue. 3.16 and 3.17 was installed.i disabled Nunit3TestAdapter in Tools->Extensions and Updates.
Now its working

@OsirisTerje
Copy link
Member

@justcode411 I would assume you have the same problem, nice if you can confirm.

@svetvasilev
Copy link

Hi, I experience the same issue even though it is marked as closed. My setup is VS 2015 Upd3, project targeting .NET 4.6. Test project was created with the NUnit VS templates add-on. Using nUnit v3.12, nUnit test adapter v3.17 through the nuget package only.
Initially I experienced the exact same behavior as above since I had the VSIX variant of the adapter installed as well. Tried to first disable it - no change. Removed it completely - the behaviour changed slightly. Now I am able to run tests more often than only once. yet after few runs the same error with the NullReferenceException upon test discovery occurs. Just closing the solution and opening again in the same VS instance seems to do the trick, but it is very unproductive.

@OsirisTerje
Copy link
Member

OsirisTerje commented Aug 20, 2020

@svetvasilev Have you tried deleting the VSTest vsix cache ? See #261 (comment)

@svetvasilev
Copy link

@OsirisTerje - tried this one with some mixed outcome. Cleaned the cache several times as per #261 but the behaviour prevailed. Then I noticed that for some strange reason the NUnit adapter VS extension was still hanging around, though disabled. I uninstalled it then for good (for second time), restarted VS and then the adapter seemed to be loaded correctly and tests are possible to execute.
However since then what is happening is that each time when i try to run tests for very first time from context menu in code->Run Tests i still get the exact same exception. Same happens if i open the Test Explorer and try to run the tests from there.
This is somewhat intermittent as once i restart VS the adapter starts behaving as expected. But i have to occasionally restart VS which is a bit annoying.
Perhaps it has smthg to do with the tooling i have in this VS instance. I still use 2015 since i work with BizTalk server, which requires this VS version for the dev experience to function properly. I have as well SSDT and SSDT BI installed. I have in addition VS 2017 installed side-by-side.

@OsirisTerje
Copy link
Member

@svetvasilev Is this limited to ONE specific machine, or does it also happen on other machines, e.g. your colleagues machines ?

@svetvasilev
Copy link

@OsirisTerje - will reach out to others from the teams to try this out as the tests are for projects that only I work with. Havent tried it on buid server as of now either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirm We need a separate confirmation of this issue
Projects
None yet
Development

No branches or pull requests

6 participants