3. SOAPSonar – Run View with Chaining

If you have not, please do Starting with SOAP and REST Tutorial first.

Automation lets you test the business flow scenarios. So now lets model a very simply business flow. Lets take an example, the company uses a 3rd party API for calculating distance between cities. This is a REST service. They have a second API that they use to calculate. The Client application makes use of both. The test requirements are that users are expected to calculate the time it would take to ride a bicycle between Toronto and Montreal if you travelled and average speed of 20 km/h. To do this we set up out test cases in project view and run it in Run View. But to automate this, we need the response from one service to be the input into the second. This we at ST3PP refer to chaining services for automation.

SOAPSonar Test Cycle

TUTORIAL

1. Open SOAPSonar, and lets first add the REST distance service. In this case I am going to use Google Maps. File, New, Test Group. Then right-click on Tests in the Project Tree and select New REST Test. It’s always good to give names to things, so right click on New Test_1 and Name it Distance.

1 Distance

2. Paste the following in to URI field.

http://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&sensor=false&avoid=highways&mode=bicycling Make sure Method is GET and then Commit and Send.

2 Send

3. In the Response section we interested in the distance. Unless Montreal and Toronto are floating apart, you should get 621 km at 1 day 8 hours. But at what speed? Select the tab Runtime Variables, then scroll down till you get the distance value field of 621476 (meters). Select this value number and right-clickAdd Variable Reference. Name it Distance. OK, Commit.

3 add vairable

4. In Tutorial 2 we used a SOAP calculate function, lets add that. Since SOAP comes with WSDL, just paste

http://www.html2xml.nl/Services/Calculator/Version1/Calculator.asmx?wsdl into the capture WSDL bar.

4. capture calc

5. Now on Divide_1right-click and Clone,  twice. Renaming the the first to KM and the second to Hours.

5 Clone

6. Select KM and we need to enter the response from distance in Meters, into a = and b= should be 1000, the response needs to go into hours. in a= right-click, [RV] Runtime Variable, New Custom Group, distance. Set b= to 1000. Then Commit and Send.

6 KM

7. In the Response tab,  select Runtime Variables, then Divide Result and right-click. Add Variable Reference and name it Distance_KM. Notice the tab shows Runtime Variables (1) now?

7 RV km

8. Lastly we need to divide that response by 20 km/h. Select Hours in the project tree, in a= right-click, Select [RV] Runtime Variable, Calculator.asmx, Distance_KM variable. then b=20. This should be the result we have being asked to model.

8 Hours

9. Switch to Run View and drag Hours test case under the DefaultGroup. We should name that our scenario.Notice that Distance and KM are known prerequisites and so get added automatically.

9 Run view

10. Make sure we use the Test Case Success Criteria as we have not captured a baseline and lets Log Fail Only. Make sure you not Publishing this to HP Quality Center Project. Commit and Run suite.

10. Run

Conclusion

You automatically placed into Real Run Monitor, but we talk about Report view and logs in next post. Save your project as Tut3.

You have just automated a test scenario of 3 unit tests across both REST and SOAP API’s that reside on different systems and at different locations (external) to your network. Yes you could have done this faster manually the first time, but we will look at ways to baseline and monitor as well as use this example for more locations or different speeds.

Comments? Please share any thoughts or provide feedback so others can learn.