.NET unit testing: How to use web.config

When I start out with .NET unit testing, I have a method that uses connection string from web.config.

I run this test, it leaves me with null reference exceptions!

So how do we use the web.config file with the test project?

Solution: Adding new config file for the test project.

Right click on test project, choose Add -> New Item -> Application Configuration File. Copy the configs in web.config into new file.

Run test again. It'll work!




Comments