NullReferenceException running NUnit 3 tests

I am facing the same issue as this person:

https://groups.google.com/forum/#!topic/nunit-discuss/ZOsHZmjXCD4

I was able to run and debug our tests using the NUnit runner built into Visual Studio 2015 the whole day until it suddenly stopped working. Now every time I try to run or debug the tests I get the same issue. I tried upgrading to the latest VS 2017, upgrading Resharper to the latest, uninstalling and reinstalling everything but nothing changes. Even when I point the NUnit console runner to a NuGet version I see the same issue. I have tried disabling shadow assemblies and every setting I can find but nothing helps. I tried deleting the NUnit settings in the AppData folder but also no effect

---------------------------
ReSharper Ultimate – System.NullReferenceException: Object reference not set to an instance of an object.
---------------------------
   at NUnit.Engine.Internal.ServerBase.Start()
 
   at NUnit.Engine.Services.TestAgency.StartService()
 
   at NUnit.Engine.Services.ServiceManager.StartServices()
 
   at NUnit.Engine.TestEngine.GetRunner(TestPackage package)
 
   at JetBrains.ReSharper.UnitTestRunner.nUnit30.BuiltInNUnitRunner.<>c__DisplayClass1.<RunTests>b__0()
 
   at JetBrains.ReSharper.UnitTestRunner.nUnit30.BuiltInNUnitRunner.WithExtensiveErrorHandling(IRemoteTaskServer server, Action action)
---------------------------
OK   
---------------------------

 

6 comments
Comment actions Permalink

It turns out that some process (I assume resharper-related) deleted the solution team-shared file which must have caused the above issue. When I reverted that change in git the runner started working again

0
Comment actions Permalink

I'm now also getting this issue - but can't quite figure out why... what "solution team-shared" file is it you are referring to above?

0
Comment actions Permalink

@Jens 

I had this issue too, but for me it was my mistake. I'd edited a custom App.Config file in my Unit Test (making the App.Config file invalid - a config section was in the wrong place) and got this error.

Also, I was using NUnit.

I disabled the ability to run NUnit tests (Resharper > Options > Tools > Unit Testing > NUnit).

Then tried to run the tests in VS Test Explorer.

VS Test Explorer showed me the underlying error. 

 

5
Comment actions Permalink

@madebybear

Same thing happen do me, It does cause by an invalid App.Config file.

After read madebybear's comment, I found a lot of ConfigrationError exception from VS "Diagnostic Tools" Window "Events" Tab (this need VS Enterprise version to see)

But I guess you should be able to see this from "Output" window as well if you turn on "Exception Messages".Or change your "Exception Settings" to enable everything. (not tested.)

0
Comment actions Permalink

I had the same issue, fixing app.config fixed it.
Still, I would expect resharper show a much more meaningful exception.

0
Comment actions Permalink

I ran into the same issue running NUnit tests from Resharper in a Net.Core test project and despite setting Resharper>Options>Unit Testing>General>Log entries severity to Trace I couldn't see any meaningful info about what was wrong in the config file.
I ran the test within Visual Studio 2017 Test Explorer which obligingly told me exactly which section was giving the error in the config file and how to solve it.
In the process I found a lot of posts about renaming the app.config file to something like testprojectname.dll.config but this was just noise. As soon as there is an app.config file in the project, named app.config or defined by an <appConfig> tag or a link to a config file in an other project in the csproj, NUnit will attempt to read it and throw this useless exception if there is an issue with the file.
About the config file itself, there is no need to set its output to copy if newer or copy always, its content is now automatically present in the testprojectname.dll.config in the output directory.
Finally, as mentioned here https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard you need to install both Microsoft.NET.Test.Sdk and NUnit3TestAdapter to run the tests from VS Test Explorer whereas there is no need for either of them running for Resharper.

0

Please sign in to leave a comment.