Advanced Principles of API Testing | Part 1 Presented - - PDF document

advanced principles of api testing part 1
SMART_READER_LITE
LIVE PREVIEW

Advanced Principles of API Testing | Part 1 Presented - - PDF document

W4 API Testing Wednesday, October 23rd, 2019 10:15 AM Advanced Principles of API Testing | Part 1 Presented by: Varuna


slide-1
SLIDE 1

¡ ¡ W4 ¡

API ¡Testing ¡ Wednesday, ¡October ¡23rd, ¡2019 ¡10:15 ¡AM ¡ ¡ ¡ ¡ ¡

Advanced ¡Principles ¡of ¡API ¡Testing ¡| ¡ Part ¡1 ¡ ¡

Presented ¡by: ¡ ¡ ¡

¡ Varuna ¡Srivastava ¡

¡ ThoughtWorks ¡Canada ¡ ¡

Brought ¡to ¡you ¡by: ¡ ¡ ¡ ¡

¡

¡

¡ ¡

888-­‑-­‑-­‑268-­‑-­‑-­‑8770 ¡·√·√ ¡904-­‑-­‑-­‑278-­‑-­‑-­‑0524 ¡-­‑ ¡info@techwell.com ¡-­‑ ¡http://www.starcanada.techwell.com/ ¡ ¡ ¡

¡

¡

slide-2
SLIDE 2

¡ ¡

¡

Varuna ¡Srivastava ¡

¡ Varuna ¡is ¡a ¡technical ¡tester ¡who's ¡worked ¡on ¡award-­‑winning ¡projects ¡across ¡a ¡wide ¡ variety ¡of ¡technology ¡sectors, ¡including ¡retail, ¡travel, ¡financial, ¡and ¡the ¡public ¡sector, ¡ and ¡worked ¡with ¡various ¡web, ¡mobile, ¡and ¡IoT ¡technologies. ¡Varuna ¡is ¡a ¡passionate ¡ advocate ¡of ¡shipping ¡quality ¡code ¡to ¡production ¡using ¡agile ¡practices. ¡When ¡not ¡ working, ¡Varuna ¡likes ¡to ¡get ¡her ¡hands ¡dirty ¡experimenting ¡with ¡her ¡culinary ¡skills. ¡ Most ¡of ¡her ¡weekends ¡are ¡spent ¡in ¡cookgraphy—cooking ¡plus ¡photography! ¡ ¡

slide-3
SLIDE 3

Advanced Principles of API Testing

slide-4
SLIDE 4

About Me

  • @vibranttester
slide-5
SLIDE 5

Agenda

  • Role of API’s
  • API architecture
  • What is API testing
  • Types of api testing
  • API documentation tools
  • API design patterns
  • API Test automation
slide-6
SLIDE 6

Web services

Sends test request @vibranttester

slide-7
SLIDE 7

Web services

Sends test request @vibranttester

slide-8
SLIDE 8

REST architecture

@vibranttester

slide-9
SLIDE 9

API architecture

@vibranttester Http headers Http response Http verbs Http body

slide-10
SLIDE 10

Http verbs

@vibranttester POST DELETE PUT GET

slide-11
SLIDE 11

Http headers

@vibranttester Authorization Cache Control Content Type Set Cookie

slide-12
SLIDE 12

Http headers → Set headers

@vibranttester

slide-13
SLIDE 13

Http Response

@vibranttester

slide-14
SLIDE 14

Rest API structure

@vibranttester

slide-15
SLIDE 15

API Testing

slide-16
SLIDE 16

Test Pyramid

Sends test request @vibranttester

slide-17
SLIDE 17

API Testing (Adapted from watirmelon blog)

request @vibranttester

slide-18
SLIDE 18

Types Of API Testing

slide-19
SLIDE 19

Types of API Testing

@vibranttester

slide-20
SLIDE 20

API Functional Tests

@vibranttester

  • Focus on testing the functionality of respective api with valid inputs

/searchItem By name By brand Responsibility : ❖ Define scope of api ❖ Verify edge case scenario ❖ Verify handled error scenario

slide-21
SLIDE 21

API Contract Tests

@vibranttester

  • Focus on the messages that flow between a consumer and provider

/orders Responsibility : ❖ bugs in the consumer ❖ misunderstanding from the consumer about end-points or payload ❖ breaking changes by the provider on end-points or payload

slide-22
SLIDE 22

API Load Tests

@vibranttester

  • Focus on verifying whether the theoretical solution works as a practical

solution under a given load. Responsibility : ❖ Verify how scalable apis are at maximum user load ❖ Verify how quickly apis respond i.e speed ❖ Verify if the apis are stable under varying loads

slide-23
SLIDE 23

API Security Tests

@vibranttester

  • Focus is to make your data safe from hackers, and ensure that the API

is as safe as possible Responsibility : ❖ Validated external threats ❖ Fuzz Testing ❖ Penetration testing

slide-24
SLIDE 24

API Documentation

slide-25
SLIDE 25

Swagger

Sends test request @vibranttester

slide-26
SLIDE 26

API Blueprint

Sends test request @vibranttester

slide-27
SLIDE 27

Dredd commands

@vibranttester

slide-28
SLIDE 28

Dredd result

https://app.apiary.io/public/tests/run/a017f6eb-e89e-4afe-8d49-327559c08d24

@vibranttester

slide-29
SLIDE 29

API Design Patterns

slide-30
SLIDE 30

Design Patterns

Sends test request @vibranttester

slide-31
SLIDE 31

Why Design Patterns in Test Automation?

Sends test request @vibranttester

Reliability Scalability

Flexibility

Reusability Maintain ability

slide-32
SLIDE 32

Types of Design Patterns

Sends test request @vibranttester

Creational

Behavioural Structural

slide-33
SLIDE 33

Structural Design Patterns

slide-34
SLIDE 34

Structural Design Pattern

@vibranttester

Structural Design Patterns are used to avoid duplicates in code and increase the readability and navigation of code in project

slide-35
SLIDE 35

◊Page Object Pattern

@vibranttester

HomePage Search Result Page Search Item Item Search Tests

slide-36
SLIDE 36

◊Page Object Pattern

@vibranttester

SearchItemTests.java SearchItemPage.java

SearchItemId.java Tests and method invocations Method assertions Identifier of an element

slide-37
SLIDE 37

◊Page Object Pattern

@vibranttester

slide-38
SLIDE 38

◊Page Factory Pattern

@vibranttester

Page Factory Pattern encapsulates page’s attribute by findby annotations.It helps to work directly with page fields hiding the low level complexity.

slide-39
SLIDE 39

◊Page Factory Pattern

@vibranttester

slide-40
SLIDE 40

◊Page Factory Pattern

@vibranttester

slide-41
SLIDE 41

◊Page Factory Pattern

@vibranttester

slide-42
SLIDE 42

◊Chain of Invocation Pattern

@vibranttester

Chain of invocation helps to avoid repeating object again and again before method invocations and makes code pretty!!

slide-43
SLIDE 43

◊Chain of Invocation Pattern

@vibranttester

slide-44
SLIDE 44

◊Chain of Invocation Pattern

@vibranttester

slide-45
SLIDE 45

◊Chain of Invocation Pattern

@vibranttester

slide-46
SLIDE 46

◊Strategy Design Pattern

@vibranttester

Strategy pattern is used whenever we want to have more than one implementations of the same action

  • differently. It makes code more flexible and

maintainable by using separation of concepts.

slide-47
SLIDE 47

Data Design Patterns

slide-48
SLIDE 48

Data Design Pattern

@vibranttester

Data Design Patterns are used to separate data and test logic.It reduces amount of data related code from test class.

slide-49
SLIDE 49

◊Value Object Pattern

@vibranttester

Value Object makes code more readable and it reduces amount of repeatable

  • constructions. It is immutable which avoid

modifications and extensions.

slide-50
SLIDE 50

◊Builder Pattern

@vibranttester

Builder pattern makes process of building complex object easier.We don’t have to create multiple constructor for different scenario.

slide-51
SLIDE 51

◊DataProvider Pattern

@vibranttester

DataProvider pattern used to provide parameters to a test. A test method will be executed using the same instance of the test class to which the test method belongs.

slide-52
SLIDE 52

Creational Design Patterns

slide-53
SLIDE 53

◊ Singleton Pattern

@vibranttester

Singleton class has only one instance, which provides a global access point to this instance.Singleton object is initialized

  • nly when it’s requested for the first time.
slide-54
SLIDE 54

◊ Singleton Pattern

@vibranttester

Example?

slide-55
SLIDE 55

◊ Singleton Pattern

@vibranttester

Example?

slide-56
SLIDE 56

Let’s try this out !! API Test Automation

slide-57
SLIDE 57

Comments..?Doubts..?Complains..?

Drop a note @vibranttester to continue this conversation

Varuna Srivastava

LEAD QUALITY ANALYST varunas@thoughtworks.com | thoughtworks.com

slide-58
SLIDE 58