Unit testing with web services

I’m currently using visual studio 2008 unit testing to develop a class library, and into the library I put one of my classes that calls a web service. So I added a service reference to the class library.

But when I tried to test something that intantated the web service client, I kept getting weird errors as I ran the unit test.

It turns out that when I copied the app.config from the class library that included the web service definitions into the app.config of the unit testing project, the error went away. I’m not sure why the debugging project needs to have the service definitions.

Advertisement

2 Responses to “Unit testing with web services”

  1. Robbert Says:

    I ran into the same problem.. but if you think about it it’s quite logical unit test are run isolated in a seperate folders and if you don’t specify that the testing framework also needs to deploy the app.config file it will not be copied by the framework… and thus the test will result in an error. So instead of adding the app.config file to your test project, edit the Local.testsettings and tell it to deploy the app.config too.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.