API Automation Testing
Using Retrofit & Cucumber
June 2, 2018
Axon Active Vietnam - https://www.axonactive.com
Axon Active Da Nang - Axon Vibe Automation Team
June 2, 2018 Basel Department - Automation Team 2
Axon Vibe Automation Team
Agenda
• Context – How the Future of Test Automation Affects You
• Techniques – Introduce Cucumber & Retrofit 2
• Demo – Project Demo and Mini Demo
• Practices – Assignment for Audience
• Q&A
June 2, 2018 Basel Department - Automation Team 3
Context
June 2, 2018 Basel Department - Automation Team 4
Context
June 2, 2018 Basel Department - Automation Team 5
Context
June 2, 2018 Basel Department - Automation Team 6
Cucumber
What is Behaviors Driven Development?
June 2, 2018 Basel Department - Automation Team 7
Cucumber
Examples
Scenario: get all articles
When requesting get all articles
Then the request get all articles successfully
Scenario: create an article
When requesting create an article
Then the request creating an article successfully
June 2, 2018 Basel Department - Automation Team 8
Cucumber
What are the benefits?
• It is helpful to involve business
stakeholders who can't easily read
code
• Cucumber focuses on end-user
experience
• Style of writing tests allow for
easier reuse of code in the tests
• Quick and easy set up and
execution
• Efficient tool for testing
June 2, 2018 Basel Department - Automation Team 9
Retrofit 2
What is Retrofit?
• Retrofit is a type-safe HTTP client for Android
and Java
• Developed by Square, Inc.
June 2, 2018 Basel Department - Automation Team 10
How to use Retrofit
June 2, 2018 Basel Department - Automation Team 11
How to use Retrofit
June 2, 2018 Basel Department - Automation Team 12
How to use Retrofit
June 2, 2018 Basel Department - Automation Team 13
How to use Retrofit
June 2, 2018 Basel Department - Automation Team 14
• Interface to declare HTTP request
• Object to map with returned JSON data
• Retrofit builder
How to use Retrofit
June 2, 2018 Basel Department - Automation Team 15
Interface
How to use Retrofit
Interface
June 2, 2018 Basel Department - Automation Team 16
How to use Retrofit
June 2, 2018 Basel Department - Automation Team 17
• Interface to declare HTTP request
• Object to map with returned JSON data
• Retrofit builder
How to use Retrofit
June 2, 2018 Basel Department - Automation Team 18
How to use Retrofit
Object
June 2, 2018 Basel Department - Automation Team 19
How to use Retrofit
June 2, 2018 Basel Department - Automation Team 20
• Interface to declare HTTP request
• Object to map with returned JSON data
• Retrofit builder
How to use Retrofit
Adapter
June 2, 2018 Basel Department - Automation Team 21
How to use Retrofit
Interface
June 2, 2018 Basel Department - Automation Team 22
How to use Retrofit
Instantiate an implement of interface class
June 2, 2018 Basel Department - Automation Team 23
How to use Retrofit
Send request to API
June 2, 2018 Basel Department - Automation Team 24
Mini - Demo
Structure of
Framework:
June 2, 2018 Basel Department - Automation Team 25
Mini - Demo
Configure url in local.properties file to build baseURL
June 2, 2018 Basel Department - Automation Team 26
Mini - Demo
Workflow of
Framework:
June 2, 2018 Basel Department - Automation Team 27
Practices
URL - http://dummy.restapiexample.com
June 2, 2018 Basel Department - Automation Team 28
Practices
Feature: Employee
As a user, I want to update and delete information for
employee
Scenario: Update Employee - PUT: v1/update/{id}
Scenario: Delete Employee - DELETE: v1/delete/{id}
June 2, 2018 Basel Department - Automation Team 29
Assignment
Practices
Gitlab to get codebase:
https://gitlab.com/ttthu.dsna/api-automation-retrofit
June 2, 2018 Basel Department - Automation Team 30
Practices
Push your code on Jenkins to build
June 2, 2018 Basel Department - Automation Team 31
June 2, 2018 Basel Department - Automation Team 32
June 2, 2018 Basel Department - Automation Team 33

[DN Scrum Breakfast] API Automation Testing Using Retrofit & Cucumber

  • 1.
    API Automation Testing UsingRetrofit & Cucumber June 2, 2018 Axon Active Vietnam - https://www.axonactive.com Axon Active Da Nang - Axon Vibe Automation Team
  • 2.
    June 2, 2018Basel Department - Automation Team 2 Axon Vibe Automation Team
  • 3.
    Agenda • Context –How the Future of Test Automation Affects You • Techniques – Introduce Cucumber & Retrofit 2 • Demo – Project Demo and Mini Demo • Practices – Assignment for Audience • Q&A June 2, 2018 Basel Department - Automation Team 3
  • 4.
    Context June 2, 2018Basel Department - Automation Team 4
  • 5.
    Context June 2, 2018Basel Department - Automation Team 5
  • 6.
    Context June 2, 2018Basel Department - Automation Team 6
  • 7.
    Cucumber What is BehaviorsDriven Development? June 2, 2018 Basel Department - Automation Team 7
  • 8.
    Cucumber Examples Scenario: get allarticles When requesting get all articles Then the request get all articles successfully Scenario: create an article When requesting create an article Then the request creating an article successfully June 2, 2018 Basel Department - Automation Team 8
  • 9.
    Cucumber What are thebenefits? • It is helpful to involve business stakeholders who can't easily read code • Cucumber focuses on end-user experience • Style of writing tests allow for easier reuse of code in the tests • Quick and easy set up and execution • Efficient tool for testing June 2, 2018 Basel Department - Automation Team 9
  • 10.
    Retrofit 2 What isRetrofit? • Retrofit is a type-safe HTTP client for Android and Java • Developed by Square, Inc. June 2, 2018 Basel Department - Automation Team 10
  • 11.
    How to useRetrofit June 2, 2018 Basel Department - Automation Team 11
  • 12.
    How to useRetrofit June 2, 2018 Basel Department - Automation Team 12
  • 13.
    How to useRetrofit June 2, 2018 Basel Department - Automation Team 13
  • 14.
    How to useRetrofit June 2, 2018 Basel Department - Automation Team 14 • Interface to declare HTTP request • Object to map with returned JSON data • Retrofit builder
  • 15.
    How to useRetrofit June 2, 2018 Basel Department - Automation Team 15 Interface
  • 16.
    How to useRetrofit Interface June 2, 2018 Basel Department - Automation Team 16
  • 17.
    How to useRetrofit June 2, 2018 Basel Department - Automation Team 17 • Interface to declare HTTP request • Object to map with returned JSON data • Retrofit builder
  • 18.
    How to useRetrofit June 2, 2018 Basel Department - Automation Team 18
  • 19.
    How to useRetrofit Object June 2, 2018 Basel Department - Automation Team 19
  • 20.
    How to useRetrofit June 2, 2018 Basel Department - Automation Team 20 • Interface to declare HTTP request • Object to map with returned JSON data • Retrofit builder
  • 21.
    How to useRetrofit Adapter June 2, 2018 Basel Department - Automation Team 21
  • 22.
    How to useRetrofit Interface June 2, 2018 Basel Department - Automation Team 22
  • 23.
    How to useRetrofit Instantiate an implement of interface class June 2, 2018 Basel Department - Automation Team 23
  • 24.
    How to useRetrofit Send request to API June 2, 2018 Basel Department - Automation Team 24
  • 25.
    Mini - Demo Structureof Framework: June 2, 2018 Basel Department - Automation Team 25
  • 26.
    Mini - Demo Configureurl in local.properties file to build baseURL June 2, 2018 Basel Department - Automation Team 26
  • 27.
    Mini - Demo Workflowof Framework: June 2, 2018 Basel Department - Automation Team 27
  • 28.
    Practices URL - http://dummy.restapiexample.com June2, 2018 Basel Department - Automation Team 28
  • 29.
    Practices Feature: Employee As auser, I want to update and delete information for employee Scenario: Update Employee - PUT: v1/update/{id} Scenario: Delete Employee - DELETE: v1/delete/{id} June 2, 2018 Basel Department - Automation Team 29 Assignment
  • 30.
    Practices Gitlab to getcodebase: https://gitlab.com/ttthu.dsna/api-automation-retrofit June 2, 2018 Basel Department - Automation Team 30
  • 31.
    Practices Push your codeon Jenkins to build June 2, 2018 Basel Department - Automation Team 31
  • 32.
    June 2, 2018Basel Department - Automation Team 32
  • 33.
    June 2, 2018Basel Department - Automation Team 33

Editor's Notes

  • #2 Divide everyone to 5 groups and send link to get source code for them Guide them to config to run source code
  • #5 Most software testing right now is done by manual testers, while automation represents no more than 30% of testing.  Also notice that of the automated testing done, the vast majority of it is UI testing. http://typescriptprotractor.blogspot.com
  • #7 Most software testing right now is done by manual testers, while automation represents no more than 30% of testing.  Also notice that of the automated testing done, the vast majority of it is UI testing. http://typescriptprotractor.blogspot.com