29
testing web services TIME TO REST

Time to REST: testing web services

Embed Size (px)

Citation preview

testing web services

TIME TO REST

Who am I

Iurii Kutelmakhemail: [email protected]

skype: ykutelmakh

linkedIn: linkedin.com/in/ykutelmakh

Senior QA Engineer@ DataArt

Director, lecturer

@ Lviv IT School

DJ@ Sunday Sofa Podcast

AGENDAweb servicesSOAP vs RESTful

web services testing: from manual to automation

web services

Web services are open standard (XML, SOAP, HTTP etc.) based web applications that interact with other

web applications for the purpose of exchanging data

web services characteristics:- document based (xml / json)- cross platform- widely available (http / ftp)- synchronous / asynchronous

Standart SOAP service components:• SOAP (Simple Object Access Protocol)• UDDI (Universal Description, Discovery and Integration)• WSDL (Web Services Description Language)

soap request soap response

HTTP/1.1 200 OKCache-Control: no-cache, no-store, max-age=0, must-revalidateDate: Wed, 14 Jan 2015 15:33:32 GMTPragma: no-cacheContent-Length: 122Content-Type: application/xmlAccept: application/xml. . .

<?xml version="1.0" encoding="utf-8" ?> <SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...> <SOAP-ENV:Body> <method:GetCustomerInfoResponse>

<name>Test Name</name><phone>+380000000000</phone><street1>Hutorivka 35</street1><street2></street2><city>Lviv</city><state></state><postalcode>79000</postalcode><country>Ukraine</country>

<method:OutputParam>Value</method:OutputParam> </method:GetCustomerInfoResponse></SOAP-ENV:Body>

</SOAP-ENV:Envelope>

POST http://{url}?parameter=value HTTP/1.1Host: HostServerNameContent-type: text/xml; charset=utf-8Content-length: 350SoapAction: http://tempUri.org/GetCustomerInfo...

<?xml version="1.0" encoding="utf-8" ?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <GetCustomerInfo xmlns="http://tempUri.org/">

<CustomerID>18102016</CustomerID> <OutputParam />

</GetCustomerInfo></soap:Body></soap:Envelope>

REST (Representational State Transfer)

architectural style for distributed hypermedia systems, describing the software engineering principles guiding REST and the interaction constraints chosen to retain those principles,

while contrasting them to the constraints of other architectural styles.

stateful vs stateless

stateful means that there is memory of the past. Previous transactions are remembered and may affect the current transaction.

stateless means there is no memory of the past. Every transaction is performed as if it were being done for the very first time.

The Representational State Transfer (REST) style is an abstraction of the architectural elements within a distributed hypermedia system.

The key abstraction of information in REST is a resource

1. Uniform Interface Individual resources are identified using URLs.2. Stateless InteractionsNone of the clients context is to be stored on the server side between the request.3. CacheableClients can cache the responses.4. Client-ServerThe clients and the server are separated from each other.5. Layered SystemAt any time client cannot tell if it is connected to the end server or to an intermediate. 6. Code on DemandAn optional constraint where the server temporarily extends the functionality of a client by the transfer of executable code.

HATEOAS stands for Hypertext As The Engine Of Application State. It means that hypertext should be used to find your way through the API.

GET /account/12345 HTTP/1.1

HTTP/1.1 200 OK<?xml version="1.0"?><account> <account_number>12345</account_number> <balance currency="usd">100.00</balance> <link rel="deposit" href="/account/12345/deposit" /> <link rel="withdraw" href="/account/12345/withdraw" /> <link rel="transfer" href="/account/12345/transfer" /> <link rel="close" href="/account/12345/close" /></account>

web services testing

good to know …

In computer programming, an application programming interface (API) is a set of subroutine definitions, protocols, and tools for building software and applications

In the simplest terms, APIs are sets of requirements that govern how one application can talk to another

good to know …

request methods:-GET-POST-PUT-DELETE-OPTIONS, TRACE, HEAD, PATCH

headers:-Cookie-Location-Date-Content-Type-etc

status codes:-100 (info)-200 (success)-300 (redirect)-400 (client error)-500 (server error)

testing technics:-functional-performance-security-static testing

Request:- boundary values- equivalence partitioningResponse:- data type- data structure- data fullness

practice

tools:- Postman- SoapUI- Automation framework (Java + TestNg + RestAssured)

thanks