Автоматизация тестирования api для начинающих

35
1 Automation of web service testing for the beginners FEBRYARY 26, 2017

Upload: comaqaby

Post on 21-Mar-2017

119 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Автоматизация тестирования API для начинающих

1

Automation of web service testing for the beginners

FEBRYARY 26, 2017

Page 2: Автоматизация тестирования API для начинающих

2

Andrei Stasevich

Experience • M.Sc. of engineering with more then 5 years

experience • Main IT specialization: Test Automation• Technology: Java, Selenium• COMAQA.by community activistAndrei Stasevich

EPAM Systems Software Test

Automation Engineer

Page 3: Автоматизация тестирования API для начинающих

3

AGENDA

Introduction to API1

What is web service2

SOAP and REST5

Examples6

Ways of communication3

Web Service testing4

Page 4: Автоматизация тестирования API для начинающих

4

INTRODUCTION TO API

Application programming interface (API) - a set of clearly defined methods of communication between various software components.

• Web service

• Libraries

• Operation system API

• Graphical/sound interfaces

Page 5: Автоматизация тестирования API для начинающих

5

API is like User Interface - just with different users in mind.

INTRODUCTION TO API

Page 6: Автоматизация тестирования API для начинающих

6

AGENDA

Introduction to API1

What is web service2

SOAP and REST5

Examples6

Ways of communication3

Web Service testing4

Page 7: Автоматизация тестирования API для начинающих

7

WHAT IS WEB SERVICE?

Web service - software system designed to support interoperable machine-to-machine interaction over a network.

• It accessible over the Internet or private networks.

• Is not tied to any one operating system or programming language.

• Used for direct application-to-application interaction.

• Uses XML (JSON) messages for interaction.

Every Web Service is an API but not every API is a Web Service

Page 8: Автоматизация тестирования API для начинающих

8

WHAT IS WEB SERVICE?

• The client bundles the information into a message (request).• Client and server establish connection and sent message as the body

of an HTTP request.• Service processes the received information.• Service packages the response, and sends it back to the client

program. • The client program unpacks the request to obtain the result.

Page 9: Автоматизация тестирования API для начинающих

9

WHAT IS WEB SERVICE?

• Establishing TCP connection.• Client sends version of the TLS protocol, the list

of supported ciphersuites, and other TLS options.

• The server picks the TLS protocol version, decides on a ciphersuite, attaches its certificate.

• The client initiates key exchange, which is used to establish the symmetric key.

• The server returns an encrypted Finished message back to the client.

• The client decrypts the message and if all is well, then the tunnel is established.

Page 10: Автоматизация тестирования API для начинающих

10

WHAT IS WEB SERVICE?center=NYzoom=13size=640x640maptype=road

GET https://maps.googleapis.com/maps/api/staticmap?center=NY&zoom=13&size=640x640&maptype=roadmap&key=AIzaSyDH7iC

centerzoomsizemaptypekey…

HTTP/1.1 200 OKContent-Type: image/png

Page 11: Автоматизация тестирования API для начинающих

11

AGENDA

Introduction to API1

What is web service2

SOAP and REST5

Examples6

Ways of communication3

Web Service testing4

Page 12: Автоматизация тестирования API для начинающих

12

WAYS OF COMMUNICATION

XML is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. XML is a language-independent data format.

JSON is an open-standard format that uses human-readable text to transmit data objects consisting of attribute–value pairs. JSON is a language-independent data format.

Page 13: Автоматизация тестирования API для начинающих

13

WAYS OF COMMUNICATION

XML (Extensible Markup Language) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable.XML was designed to describe dataXML is about carrying information – within TAGs

Tags are not predefined – make your own onesXML document does not DO anything so to say

• It is just information wrapped in tags• Custom code needed for interpretation

XML is a software - and hardware-independent tool • Used to store and transport information

Page 14: Автоматизация тестирования API для начинающих

14

WAYS OF COMMUNICATION

An XML element can contain: • Other elements• Any given text• Attributes • Mix of the previouos

Comments may appear anywhere• An example of a valid comment: <!–- the comment itself

-->

Page 15: Автоматизация тестирования API для начинающих

15

WAYS OF COMMUNICATION

JSON is an open-standard format that uses human-readable text to transmit data objects consisting of attribute–value pairs. JSON is a language-independent data format.

JSON is a syntax for storing and exchanging data • An easier-to-use alternative to XML

The JSON format is well fitted for Java and JavaScript• Very lightweight • Easy to process for services

Page 16: Автоматизация тестирования API для начинающих

16

WAYS OF COMMUNICATION

JSON's basic data types are:• Number• String• Boolean• Array• Object• null

• Square brackets hold arrays

JSON syntax is a subset of the JavaScript syntax:

• Data is in „name:value” pairs

• Data is separated by commas• Curly braces hold objects

• Interestingly, there are no comments in JSON

Page 17: Автоматизация тестирования API для начинающих

17

Page 18: Автоматизация тестирования API для начинающих

18

AGENDA

Introduction to API1

What is web service2

SOAP and REST5

Examples6

Ways of communication3

Web Service testing4

Page 19: Автоматизация тестирования API для начинающих

19

WEB SERVICE TESTING

Happy paths•Using the provided method calls•Analyzing the returned data •Trying out different parameters•Response validation

Page 20: Автоматизация тестирования API для начинающих

20

Web Service testing

Unhappy paths•Using wrong URIs •Invalid or missing parameters•See how the server responds to those•Client or server side errors

Page 21: Автоматизация тестирования API для начинающих

21

AGENDA

Introduction to API1

What is web service2

SOAP and REST5

Examples6

Ways of communication3

Web Service testing4

Page 22: Автоматизация тестирования API для начинающих

22

SOAP

SOAP (Simple Object Access Protocol) is a protocol specification for exchanging structured information in XML format.

SOA web-services:• Service provider: creates a web service and provides its information to the service broker. • Service broker UDDI: makes the information regarding the web service available to any

potential requester.• Service requester: locates entries in the broker registry using various find

operations and then binds to the service provider in order to invoke one of its web services.

Rules for communication are defined in WSDL file(Web Services Description Language):

• How one system can request data from another system.• Specific parameters.• The structure of the data. • Error messages.

Page 23: Автоматизация тестирования API для начинающих

23

WSDL

<binding> - поддерживаемые протоколы.<message> - сообщения Web-службы (запрос, ответ).<portType> — все доступные методы.<service> — URI службы.<types> — используемые типы данных.

Page 24: Автоматизация тестирования API для начинающих

24

SOAP

SOAP provides the envelope for sending Web Services messages over the HTTP/SMTP.

The SOAP envelope contains two parts:

• SOAP Header (optional): providing information on authentication, encoding of data, or how a recipient of a SOAP message should process the message.

• SOAP Body: contains the message. These messages can be defined using the WSDL specification.

Page 25: Автоматизация тестирования API для начинающих

25

SOAP

Page 26: Автоматизация тестирования API для начинающих

26

REST

Representational State Transfer (REST) is a style of architecture based on a set of principles that describe how networked resources are defined and addressed. • Client-Server

• Stateless

• Cacheable

• Layered system

• Code on demand

• Uniform interface

Page 27: Автоматизация тестирования API для начинающих

27

REST

REST-compliant Web services allow requesting systems to access and manipulate textual representations of Web resources using a uniform and predefined set of stateless operations. "Web resources" were first defined  as documents or files identified by their URLs.

POST http://www.example.com/customers

GET http://www.example.com/customers/33245DELETE http://www.example.com/customers/33245

PUT http://www.example.com/customers/33245

Page 28: Автоматизация тестирования API для начинающих

28

AGENDA

Introduction to API1

What is web service2

SOAP and REST5

Examples6

Ways of communication3

Web Service testing4

Page 29: Автоматизация тестирования API для начинающих

29

Test• Test NG, Junit, RestAssured

Service• Java

HTTP client• Apache, Retrofit

TEST FRAMEWORK

Test

ServiceLayer

HTTP client

Page 30: Автоматизация тестирования API для начинающих

30

TEST

Page 31: Автоматизация тестирования API для начинающих

31

SERVISE

Page 32: Автоматизация тестирования API для начинающих

32

HTTP CLIENT

Page 33: Автоматизация тестирования API для начинающих

33

TEST

Page 34: Автоматизация тестирования API для начинающих

34

THANKYOU

Page 35: Автоматизация тестирования API для начинающих

35

CONTACT ME

[email protected]

[email protected]

https://www.linkedin.com/in/andrei-stasevich/