This project is read-only.

Chutzpah should not cause database connections to get open.



Frist and foremost, thank you for writing Chutzpah, it's been useful for me at my organization.

We have configured Chutzpah in one of your projects. The test cases are discovered and run just fine. We're also able to run code coverage on the project. However, we are getting "Object reference not set to an instance of an object" dialog errors from Visual Studio when opening our solution (see attached screenshot). I tracked down the problem to Chutzpah.

I'm attaching a minimal case that reproduces the problem.

Basically, if you have an Entity Framework connection string in the web.config file of a solution, Chutzpah will trigger a database connection when collecting the project's items.

I debugged over chutzpah code and found the source of the error, this is the interesting part of the call trace:
VS11.Plugin.VsSolutionHelper.GetPropertyValue Line 84    <<<<<<<<<<<
VS11.Plugin.VsSolutionHelper.GetProjectItems Line 48
Chutzpah.VS2012.TestAdapter.ChutzpahTestContainerDiscoverer.FindPotentialTestFiles Line 376

It looks like the call to IVsHierarchy.GetProperty can cause database connections to get open when the project is using the Entity Framework.

If you try to open the minimal case you won't get the "Object reference not set to an instance of an object." errors, as I have cleaned the connection strings in the web.config file. But you should be seeing a "Connect to SQL Server" dialog instead. Also, if you debug Chutzpah and break on System.Data.SqlClient.SqlException, you should be getting one on the GetPropertyValue method of the VsSolutionHelper class in Chutzpah.

Also, please note that the minimal case solution can be opened without errors when you disable the Chutzpah Test Adapter plugin. We have found a work around, removing or commenting out Entity Framework's connection string in the web.config file avoids the errors to be thrown. So, fixing this is not urgent to us. However, it would be nice if Chutzpah stops triggering database connections.


file attachments


mmanela wrote Jun 30, 2014 at 4:14 PM

I tried to repro this with your sample in VS2013 but I did not get the error.

Does this still happen for you if you add a chutzpah.json file which specifies which are your test files?

MiguelIbarra wrote Jun 30, 2014 at 5:01 PM


Oh, yes. We get the error with a chutzpah.json file in place.

Note that getting the items from the project happens just before filtering them using the config file settings. So, not having a chutzpah.json file doesn't modify this problem:

In ChtuzpahTestContainerDiscoverer.cs 's FindPotentialTestFiles method:

1 return (from item in VsSolutionHelper.GetProjectItems(project)
2 let hasTestExtension = HasTestFileExtension(item)
3 let isChutzpahSettingsFile = fileProbe.IsChutzpahSettingsFile(item)
4 where !fileProbe.IsTemporaryChutzpahFile(item) && (hasTestExtension || isChutzpahSettingsFile)
                   select new TestFileCandidate
                        Path = item
GetProjectITems in line 1 above is the call triggering the database connections, the config file will get used later on like 3.

I'm also using the Visual Studio Sql Server Data Tools extensions on my machine. That could be causing the problem for me and making it not reproducible on your machine.

is there a different way to get the list of files in a project without using IVsHierarchy.GetProperty on the VS API?

Thank you for looking at this!

mmanela wrote Jun 30, 2014 at 5:40 PM

I am not sure about another way. What I am doing is a very standard way to enumerate the files.

mmanela wrote Sep 10, 2014 at 1:01 AM

I fixed this issue in commit: ec9e5b515dc9.