Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2010 Error Generating Unit Tests

I have one .NET 4 DLL for which I'm having trouble generating unit tests. I'm using VS 2010 Standard. Every other project in the solution will generate unit test stubs for classes just fine. For the other assemblies, I can go into the existing code, right click the class name, and select "Create Unit Tests". I get the selection window that follows just fine.

The one assembly that I really need to get some coverage on won't generate the test stubs using the same methodology mentioned above. I go to a class in the project/assembly, right click, select "Generate Unit Tests", and I'm met with the following error:

Unit Test Generation Error: The follow error was encountered while reading module 'xx.Core': Could not resolve type reference: [System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxx]System.Web.Routing.RouteValueDictionary

As far as I can tell, there are no direct references in the project to the framework 2.0 version of System.Web mentioned in the error message. Searching the directory that contains the project and .CS files with a tool called grepWIN to see if the text for that reference exists in any files yields zero results. Is it even possible to reference both the 2.0 and 4.0 version of the system.web dll at the same time, and if so, why would you want to do that?

Any ideas on how to get rid of this error message so that I can properly stub out some unit tests?

like image 321
user171484 Avatar asked Jul 29 '10 12:07

user171484


2 Answers

I had the same problem, with the ObservableCollection.

My "solution" was to upgrade all referenced projects and their referenced projects to .NET 4.0. Then it worked.... However this seems a bit odd and I could well have done something else that caused the problem to disappear.

like image 156
Marcel Avatar answered Oct 24 '22 13:10

Marcel


I recently had a similar problem with one of my projects. The problem was that after I had built my library I renamed the dll file. My project referencing the dll still built fine, however I received a similar error while generating unit tests until I renamed the dll back to its original name when it had been built.

like image 45
mike9182 Avatar answered Oct 24 '22 11:10

mike9182