-
Notifications
You must be signed in to change notification settings - Fork 106
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
An exception occurred while test discoverer 'NUnit3TestDiscoverer' was loading tests. Exception: Object reference not set to an instance of an object, with VS2015 #781
Comments
Added sample project. |
@saiparth Have you checked if this works with earlier versions of the adapter? |
Checked with 3.12.0 of nunit and 3.11.0 nUnit3TestAdapter after clearing temp files, |
@saiparth Thanks! That makes sense. Now, and this is might be a bit weird: Can you comment out the OneTimeSetUp and the OneTimeTearDown, and run the tests ? It should now run green. Also, can you copy the Output/Test window messages when it fails ?' (I could repro it the first time I downloaded the repro, but after that, I can't force it to fail again.....) Also, if you add the 0 to the runsettings NUnit section, oyu will suppress the writes, and then it should perform as 3.11.0. But I assume you want it printed out. |
@OsirisTerje
|
I encountered a similar problem today (same exception message in the logs) where my tests would appear on the first build, but after running once the tests and rebuilding the tests would disappear. I cleared my temp files, but the problem persisted. Installing 16.1, manually as an VS extension, in VS2015 seems to have resolved the issue. |
This issue seems bound to VS2015, not happening with VS2019. |
I am using Microsoft Visual Studio Professional 2017 Version 15.3.3 |
Can you drop a screenshot of your Test/General settings ? |
@saiparth Not able to repro with 2017, 15.9.25. Can you upgrade to that version and recheck ? Sorry, meaning: Tools/Options/Test/general |
Issue was not reproducible with Microsoft Visual Studio Professional 2017 Version 15.9.27. However it dint print the OneTimeSetUp/OneTimeTearDown |
So, this is an issue with VS 2015 and VS 2017 up to at least 15.3.3, but fixed in at least 15.9.27 and VS 2019. The workaround for those on lower versions here is then to not upgrade to 3.17. It is something with VS going on here, and I can't see that we can do anything more about this. Thanks for your reports, @saiparth ! |
It means NUnit 3.17+ doesn't support VS2015 anymore? |
@felipepessoto Yes it does, but this particular bug doesn't seem like something we can fix easily. It is triggered by the case shown, but otherwise you would be fine. You can however build your own debug version of the adapter, and then enable debugging to see if you can pinpoint something we can change in the adapter. You can also raise an issue at Developer Community and ask for what change they did between 2017 15.3 and and 15.9 - that might give a clue too. Is there a particular reason why you can't upgrade from VS 2015 ? And, if there is a bigger demand for fixing this, we could look into it, we could reopen it - but we would appreciate a bit of debugging help. |
@felipepessoto Notice you are a MSFT. You could then ask internally what changed between those two versions. That would be very helpful. |
"Is there a particular reason why you can't upgrade from VS 2015 ?" As for myself, I work in a regulated industry. My team needs to support the team's product with VS 2015 for at least the next 2 years. We are only just beginning to talk about updating our core product to 2017 next year. Essentially we don't update until Microsoft stops adding features to a version of Visual Studio and then only when we have a major release where we would run our full suite of Verification tests. My team doesn't strictly need to update as long as there is a version of the extension for VS 2015 that is stable. |
@Aaron-Corp00 Which version of the adapter are you currently using (that works) ? |
I can confirm this issue. I am on VS2015 too and experience the same behaviour (i.e. tests are only discovered once after startup of VS; after any further build operation the discovered tests are gone with the exception of the NUnit3TestDiscoverer. VERY annoying!). I could solve this issue by removing the 'Nunit 3 Test Adapter' from Tools > Extensions and Updates, restarting VS and downgrading the NuGet package 'NUnit3TestAdapter' from v3.17.0 to v3.16.1. Hope that helps! |
@OsirisTerje I'm currently running 13.6.0, which is odd because I thought I installed 13.6.1, but its working at the moment so I'll probably leave this as is. |
With VS2015, the TestAdapter's base class should initialize the internal engine adapter, but for some reason it is found to be null. This does not happen on later VS2017 and VS2019. It seems that the adapter is being kept alive, and then the engine adapter is null'ed during end of first test. This fix ensure the internal engine adapter is recreated if it is null when accessed. |
@felipepessoto @schlati @saiparth @Aaron-Corp00 I believe the error is found. I would really appreciate if you can test the package at https://www.myget.org/feed/nunit/package/nuget/NUnit3TestAdapter (NUnit3TestAdapter 4.0.0-dev-01507), and verify if it work for you in your setup. Please ensure that you have no VSIX installed. On my repro I can no longer repro the case, but it is a weird case, so I would really need your input here. |
Sorry @OsirisTerje I'm really focused in a complex work and can't test it now, since I only have my working machine to test it. |
@OsirisTerje
For above mentioned test, No exception was seen
However it dint print the OneTimeSetUp/OneTimeTearDown |
Thank you! That fixes the problem for me! (I use VS 2015 Version 14.025431.01 Update 3) |
Hello all |
@shahnawazm786 A little bit more details would be helpful. |
Steps to Repro
Firs time passes,rebuild the solution>>Observe console >>error will display as mentioned in title ,test will pass,[OneTimeSetUp] / [SetUp] will not be executed
packages.config
Close VS>>Run IFix vstestcache -f >>Rebuild>> works,first time,Test runs, later exception is thrown,One time setup not runs.
An exception occurred while test discoverer 'NUnit3TestDiscoverer' was loading tests. Exception: Object reference not set to an instance of an object
I tried all the workaround mentioned in #261
I tried removing the cache,works for first time,later again the same problem,cant restart everytime
I changed test process acritecture to 64 still same
Note
On running through nunit3-console all methods works
The text was updated successfully, but these errors were encountered: