Testing web services

54
Testing web services

description

Testing web services is very important part of integration testing on web projects. In this presentation you can learn the best approaches, tools and features of Web Services testing. Soon I'll share url with a video from my presentation.

Transcript of Testing web services

Page 1: Testing web services

Testing web services

Page 2: Testing web services

About Me

Page 3: Testing web services

Taras Lytvyn

testers.lviv.ua/automation

[email protected]

Page 4: Testing web services

Prehistory

Page 5: Testing web services

Service = web interface

+ Web service on Java

+DB usage

Page 6: Testing web services

SERVICE AS STATE MACHINE

Page 7: Testing web services

Google services

Page 8: Testing web services

Web Services

Page 9: Testing web services

What is web service ?QA point of view

Page 10: Testing web services

Examples

Page 11: Testing web services

You can find web services in Network tab

Page 12: Testing web services

Classification

Page 13: Testing web services

REST

SOAP

Page 14: Testing web services

RESTRepresentational

State Transfer

1. Give every “thing” an ID2. Link things together3. Use standard methods4. Resources can have multiple representations5. Communicate independently

Page 15: Testing web services

SOAP1. Use WSDL for description2. SOAP is approach of

protocols and standards3. Works with operationsSimple Object

Access Protocol

Page 16: Testing web services

WSDL

Web Services Description Language is an XML-based

interface description language that is used for describing the functionality offered by a web

service.

Page 17: Testing web services

Request methods

Page 18: Testing web services
Page 19: Testing web services

Content Type on response

Page 20: Testing web services

So what to test ?

Page 21: Testing web services

Response Correctness

data datatype

dataorder

fullness

Page 22: Testing web services

What else ?

Page 23: Testing web services

•client part that uses this service•http statuses•authorization• response timeout• load testing• security testing

•NEGATIVE cases !

Page 24: Testing web services

REAL EXAMPLEGET http://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536, -104.9847034|36.455556, -116.866667&sensor=true

Valid HTTP status code – 200 OK

Response timeout !>= 0.5 s

Negative cases (check status):- incorrect locations- incorrect sensor value

Page 25: Testing web services

{ "results": [ { "elevation": 1608.637939453125, "location": { "lat": 39.7391536, "lng": -104.9847034 }, "resolution": 4.771975994110107 }, { "elevation": -50.78903579711914, "location": { "lat": 36.455556, "lng": -116.866667 }, "resolution": 19.08790397644043 } ], "status": "OK"}

Page 26: Testing web services

<Response xmlns="http://maps.googleapis.com/maps/api/elevation/json"> <results> <e> <elevation>1608.637939453125</elevation> <location> <lat>39.7391536</lat> <lng>-104.9847034</lng> </location> <resolution>4.771975994110107</resolution> </e> <e> <elevation>-50.78903579711914</elevation> <location> <lat>36.455556</lat> <lng>-116.866667</lng> </location> <resolution>19.08790397644043</resolution> </e> </results> <status>OK</status></Response>

Page 27: Testing web services

So how to test ?

Page 28: Testing web services

Service MocksParsing

- xpaths- regexps

ManuallyAutomation !!!

TEST WITH:

Page 29: Testing web services

Testing features...

Page 30: Testing web services

PROBLEMS:

- SERVICE DOCUMENTATION- DBC - “DYNAMIC” RESPONSE PROBLEM

Page 31: Testing web services

SERVICE DOCUMENTATION

DOC. example

Page 32: Testing web services

DATA BASE Connectionfor reading data

Page 33: Testing web services

“Dynamic” response

Page 34: Testing web services

Tools

Page 35: Testing web services

rem curl -i -H "Content-Type: application/json" -X POST -d "11032480" http://172.22.40.73:8080/gift-registry/registry-products/5017a4d3ee12d093a5794968/delete

EXAMPLE:

Page 36: Testing web services

Manual testing

Page 37: Testing web services
Page 38: Testing web services
Page 39: Testing web services
Page 40: Testing web services
Page 41: Testing web services

SOAP UI- Support different service standards- Service mocking- Groovy & Java API- Ability of Security and Load Service

Testing- Logging results- Maven plugin +- Could be easily integrated to CI- Eclipse Plugin- Test Suite could executed with JUnit

Page 42: Testing web services

SOAP UI PROJECT SAMPLE

Page 43: Testing web services

REAL EXAMPLEGET http://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536, -104.9847034|36.455556, -116.866667&sensor=true

Valid HTTP status code – 200 OK

Response timeout !>= 0.5 s

Response correctness

Page 45: Testing web services

Response parsing

approach

Page 46: Testing web services
Page 47: Testing web services

JSON Object Library

Page 48: Testing web services

JACKSON JSON LIBRARY

Page 49: Testing web services

{ "results": [ { "elevation": 1608.637939453125, "location": { "lat": 39.7391536, "lng": -104.9847034 }, "resolution": 4.771975994110107 }, { "elevation": -50.78903579711914, "location": { "lat": 36.455556, "lng": -116.866667 }, "resolution": 19.08790397644043 } ], "status": "OK"}

Page 50: Testing web services

fill levelsCorrect

Page 51: Testing web services
Page 52: Testing web services

Conclusion

SUCCESSFUL WEB SERVICE TESTING =

SOAP UI + ECLIPSE + JAVA + JACKSON + SOAP UI JAVA API

Page 53: Testing web services

resolve all needs, approaches and

problems described earlier

Page 54: Testing web services

Thank you !