As we move forward with test automation of SOA based applications we face several challenges to automate business flows. A few of these challenges can be answered by service virtualization and service mocking.
Service virtualization is a matured and a more detailed process to help in testing and test automation, whereas in service mocking stubs are made by considering test cases or test suites.
In this chapter we will learn how to create a mock service with different techniques/dispatch methods and deploy them.
So, before we move forward, we may well ask why we need service virtualization or service mocking.
Let's take a look at a few of the challenges faced during SOA testing and test automation:
Because of the preceding issues, most of the time the test cases are not completely executed. To address the challenges we use service mocking or service virtualization techniques.
Now let's see what SoapUI has to offer in this area.
SoapUI offers a service mocking facility in its open source version.
Let's have a look at the advantages of mocking:
So let's see how we create a mock service in SoapUI.
Lets now see how to create mock services in SoapUI.
A pre-requisite is that the WSDL is already loaded in the project. In the following example, we have loaded the WSDL in the tool:
As shown in the figure preceding, select Generate SOAP Mock Service.
On the preceding screen you can see the option to select a single as well as multiple operations. To mock you can add and configure your service accordingly here such as if you want to configure the path or the port. Click on OK to proceed forward.
Now on this screen you may select any operation for which you want to further configure your mock stubs. Also from here you can change the configuration of the mock service endpoint and port details by clicking on the settings icon and you will see the following configuration window appear:
Now let's select the first operation from the previous screen GetCityForecastByZip.
So now if we need to change our response values, or response, how do we change it?
On the preceding screen if you want to change the response you can edit the response data and put any value there, shown in the following screenshot:
<html><body><p>There are currently 0 running Mock Services</p><ul></ul></p></body></html>
The preceding steps confirm the successful creation of a stub for a particular operation. You can replicate the same steps for creating stubs for other operations as well.
Now let's have a look at a different dispatch method.