Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automate test of web service communication

I have an application that sends messages to an external web service. I build and deploy this application using MSBuild and Cruisecontrol.NET. As CCNET build and deploys the app it also runs a set of test using NUnit. I'd now like to test the web service communication as well.

My idea is that as part of the build process a web service should be generated (based on the external web services WSDL) and deployed to the build servers local web server. All the web service should do is to receive the message and place it on the file system so I then can check it using ordinary NUnit for example. This would also make development easier as new developers would only have to run the build script and be up and running (not have to spend time to set up a connection to the third party service).

Are there any existing utilities out there that easily mock a web service based on a WSDL? Anyone done something similar using MSBuild?

Are there other ways of testing this scenario?

like image 298
Riri Avatar asked Aug 29 '08 16:08

Riri


2 Answers

I just started looking into http://www.soapui.org/ and it seems like it will work nicely for testing web services.

Also, maybe look at adding an abstraction layer in your web service, each service call would directly call a testable method (outside of the web scope)? I just did this with a bigger project I'm working on, and it's testability is working nicely.

like image 162
Joshua Turner Avatar answered Sep 28 '22 07:09

Joshua Turner


In general, a very good way to test things like this is to use mock objects.

At work, we use the product TypeMock to test things like Web Service communication and other outside dependencies. It costs money, so for that reason it may not be suitable for your needs, but I think it's a fantastic product. I can tell you from personal experience that it integrates very well with NUnit and CCNet.

It's got a really simple syntax where you basically say "when this method/property is called, I want you to return this value instead." It's great for testing things like network failures, files not being present, and of course, web services.

like image 25
Josh Kodroff Avatar answered Sep 28 '22 08:09

Josh Kodroff