views:

65

answers:

2
+3  Q: 

Mock web service

Hi,

We have two components: enterprise application X, and Web service Y

We want to make our (automated) testing tool that will test application X (that interact with Y) only, and we have not the web service Y available.

Notes:

  • The testing tool will be a desktop application.

  • We Don't want to use another external tools-e.g. SoapUI- for testing (as we want to automate the testing by running one application).

The question is: How we can mock the web service Y in our testing -desktop- application? Does it is easy to mock it by Socket programming, or any other method/library?

Thanks in advance,

+1  A: 

The best solution is to let application X talk to Web service Y using an interface, such as IWebServiceY.

Coupled with Dependency Injection, this allows you to inject a mock of IWebServiceY into application X instead of the real, web service-based implementation of Web Service Y.

Mark Seemann
but currently we have no modification access to application X, we should test it only as it is.
Moro
I was going to write something but then I saw this. I was going to write the same thing with different words, that is:Create a base class objInteractCreate an inherited class from objInteract that actually pokes the web service. Pass it in on the constructor whenever you'll need it.Create a 2nd inherited class that returns canned data. In test mode, pass in a pointer to that object on construction.
Matthew Heusser
+2  A: 

I found a solution in Java 6

web-services-without-ee-containers

thanks

Moro