1
END TO END TESTING: BUG SQUASHING
FOR API DEVELOPERS!
Ozan Seymen – Apigee Principal Architect
Sean Davis – Apigee Technical Specialist
API Testing - Agenda
2
©2016 Apigee. All Rights Reserved. 
•  Popular testing methodologies
•  API testing best practices
•  Popular open source tools
Test Driven Development
3
What is Test Driven Development?
• Understand the requirements
• Write tests cases first (and let them fail!)
• Write code to make tests pass
• Refactor the code often
4
©2016 Apigee. All Rights Reserved.
What is Test Driven Development?
5
©2016 Apigee. All Rights Reserved.
Why use Test Driven Development?
• Iterative development approach
• Encourages thorough testing, ensuring “quality”
• Tests are repeatable and can be automated
• Confidence when iterating or refactoring legacy code

6
©2016 Apigee. All Rights Reserved.
Challenges
• Requirements must be well understood by developer
• Focus on unit testing
• QA team test effort still high
• Maintaining set of common test cases

7
©2016 Apigee. All Rights Reserved.
Behavior Driven Development
8
BDD
9
©2016 Apigee. All Rights Reserved. 
BDD is a software development process with TDD in its heart
BDD – a software development process
10
©2016 Apigee. All Rights Reserved.
BDD – a software development process
11
©2016 Apigee. All Rights Reserved. 
Business analyst
developer
tester
BDD – a software development process
12
©2016 Apigee. All Rights Reserved. 
define /
document
automated tests
guide /
provide feedback on 
progress
specifications
Use as basis
of tests
3 Amigos
Developer
Tester
Business Analyst
BDD – Specifications
•  Express using examples 
•  Describe context, trigger and expected behaviour
•  Prioritize behaviours with business value
13
©2016 Apigee. All Rights Reserved.
BDD – Gherkin
14
©2016 Apigee. All Rights Reserved. 
•  When you come to document behavior, you need a language
•  Understood by humans and code
•  Gherkin - business readable, domain specific language
BDD – Given/When/Then
15
©2016 Apigee. All Rights Reserved. 
Feature: As an Employee I want to buy a coffee so that I wake up in
the morning

Scenario: Buy one coffee
Given there is 1 coffee left in the machine
And I have deposited 50p
When I press the coffee button
Then I should be served a coffee
BDD – Benefits of Gherkin
16
©2016 Apigee. All Rights Reserved. 
•  Documentation generation
•  Executable specifications 
•  Tooling for editors
•  Reusable snippets shared publicly 
•  Tools integration
Once you have standardized the language…
17
©2016 Apigee. All Rights Reserved.
BDD – Tooling for Automated Testing
18
©2016 Apigee. All Rights Reserved. 
APICLI
YADDA
BDD Testing with Apickli
19
github.com/apickli/apickli
•  apickli - REST API testing framework with cucumber.js
•  Open source – no relationship to Apigee
©2016 Apigee. All Rights Reserved.
Mocking
20
Mocking
•  Target API availability
– Network, ops, deployment, migrations, patches
– Parallel development
•  Constantly changing/unpredictable data
•  Simulation of certain scenarios for testing
•  When tests rely on previous data population
– e.g. forgotten password
•  High latency on target
21
©2016 Apigee. All Rights Reserved.
Mocking
•  API proxy – respond using policies
•  API proxy with node.js
•  amok open source project - https://github.com/api-bucket/amok
•  Import swagger and download server code from
http://editor.swagger.io/#/
•  Other tools:
– Mock Server
– Wire Mock
22
©2016 Apigee. All Rights Reserved.
API Proxy Testing – Environments
23
©2016 Apigee. All Rights Reserved. 
Environment
 Apigee Target
 Data
 Type of testing
DEV/TEST
 Mock Target
 Data and behavior from mocks
 Full Integration
INTG
 Actual Backend (DEV)
 Data and behavior from DEV build of
target APIs
Partial Integration
PERF
 Actual Backend (DEV/PERF)
 Data and behavior from DEV or PERF
build of target APIs
Performance
UAT
 Actual Backend (DEV/UAT)
 Data and behavior from DEV or UAT
build of target APIs
Smoke
PRE
 Actual Backend (PROD)
 Data and behavior from target APIs in
production
Smoke
PROD
 Actual Backend (PROD)
 Data and behavior from target APIs in
production
Smoke
Smoke testing – API bundle deployed properly, access all target endpoints correctly, certificates deployed
correctly, configuration is correct
Unit Testing
24
API Proxy Testing
25
©2016 Apigee. All Rights Reserved. 
Do you think it is possible to test an Apigee proxy 
fully with integration testing?

No…
API Proxy Testing – Integration test enough?
26
©2016 Apigee. All Rights Reserved. 
Isolation/Coverage
API Proxy Testing – Integration test enough?
27
©2016 Apigee. All Rights Reserved. 
Test Runner
 Apigee
 Target Systems
3rd Party
Service Callouts?
Async?
Complex code?
Unit Testing – Other benefits 
•  Code can be tested locally without deployment to Apigee first
•  Much faster than integration testing
•  Can create hooks to enforce testing during commit
28
©2016 Apigee. All Rights Reserved.
Unit Testing – Boundary Principal
29
©2016 Apigee. All Rights Reserved. 
Test within your boundaries – don’t test libraries you
don’t control
Unit Testing – Tooling
30
©2016 Apigee. All Rights Reserved.
Unit Testing
31
DEMO TIME!
Questions?
32

End to End Testing: Bug Squashing for API Developers

  • 1.
    1 END TO ENDTESTING: BUG SQUASHING FOR API DEVELOPERS! Ozan Seymen – Apigee Principal Architect Sean Davis – Apigee Technical Specialist
  • 2.
    API Testing -Agenda 2 ©2016 Apigee. All Rights Reserved. •  Popular testing methodologies •  API testing best practices •  Popular open source tools
  • 3.
  • 4.
    What is TestDriven Development? • Understand the requirements • Write tests cases first (and let them fail!) • Write code to make tests pass • Refactor the code often 4 ©2016 Apigee. All Rights Reserved.
  • 5.
    What is TestDriven Development? 5 ©2016 Apigee. All Rights Reserved.
  • 6.
    Why use TestDriven Development? • Iterative development approach • Encourages thorough testing, ensuring “quality” • Tests are repeatable and can be automated • Confidence when iterating or refactoring legacy code 6 ©2016 Apigee. All Rights Reserved.
  • 7.
    Challenges • Requirements must bewell understood by developer • Focus on unit testing • QA team test effort still high • Maintaining set of common test cases 7 ©2016 Apigee. All Rights Reserved.
  • 8.
  • 9.
    BDD 9 ©2016 Apigee. AllRights Reserved. BDD is a software development process with TDD in its heart
  • 10.
    BDD – asoftware development process 10 ©2016 Apigee. All Rights Reserved.
  • 11.
    BDD – asoftware development process 11 ©2016 Apigee. All Rights Reserved. Business analyst developer tester
  • 12.
    BDD – asoftware development process 12 ©2016 Apigee. All Rights Reserved. define / document automated tests guide / provide feedback on progress specifications Use as basis of tests 3 Amigos Developer Tester Business Analyst
  • 13.
    BDD – Specifications • Express using examples •  Describe context, trigger and expected behaviour •  Prioritize behaviours with business value 13 ©2016 Apigee. All Rights Reserved.
  • 14.
    BDD – Gherkin 14 ©2016Apigee. All Rights Reserved. •  When you come to document behavior, you need a language •  Understood by humans and code •  Gherkin - business readable, domain specific language
  • 15.
    BDD – Given/When/Then 15 ©2016Apigee. All Rights Reserved. Feature: As an Employee I want to buy a coffee so that I wake up in the morning Scenario: Buy one coffee Given there is 1 coffee left in the machine And I have deposited 50p When I press the coffee button Then I should be served a coffee
  • 16.
    BDD – Benefitsof Gherkin 16 ©2016 Apigee. All Rights Reserved. •  Documentation generation •  Executable specifications •  Tooling for editors •  Reusable snippets shared publicly •  Tools integration Once you have standardized the language…
  • 17.
    17 ©2016 Apigee. AllRights Reserved.
  • 18.
    BDD – Toolingfor Automated Testing 18 ©2016 Apigee. All Rights Reserved. APICLI YADDA
  • 19.
    BDD Testing withApickli 19 github.com/apickli/apickli •  apickli - REST API testing framework with cucumber.js •  Open source – no relationship to Apigee ©2016 Apigee. All Rights Reserved.
  • 20.
  • 21.
    Mocking •  Target APIavailability – Network, ops, deployment, migrations, patches – Parallel development •  Constantly changing/unpredictable data •  Simulation of certain scenarios for testing •  When tests rely on previous data population – e.g. forgotten password •  High latency on target 21 ©2016 Apigee. All Rights Reserved.
  • 22.
    Mocking •  API proxy– respond using policies •  API proxy with node.js •  amok open source project - https://github.com/api-bucket/amok •  Import swagger and download server code from http://editor.swagger.io/#/ •  Other tools: – Mock Server – Wire Mock 22 ©2016 Apigee. All Rights Reserved.
  • 23.
    API Proxy Testing– Environments 23 ©2016 Apigee. All Rights Reserved. Environment Apigee Target Data Type of testing DEV/TEST Mock Target Data and behavior from mocks Full Integration INTG Actual Backend (DEV) Data and behavior from DEV build of target APIs Partial Integration PERF Actual Backend (DEV/PERF) Data and behavior from DEV or PERF build of target APIs Performance UAT Actual Backend (DEV/UAT) Data and behavior from DEV or UAT build of target APIs Smoke PRE Actual Backend (PROD) Data and behavior from target APIs in production Smoke PROD Actual Backend (PROD) Data and behavior from target APIs in production Smoke Smoke testing – API bundle deployed properly, access all target endpoints correctly, certificates deployed correctly, configuration is correct
  • 24.
  • 25.
    API Proxy Testing 25 ©2016Apigee. All Rights Reserved. Do you think it is possible to test an Apigee proxy fully with integration testing? No…
  • 26.
    API Proxy Testing– Integration test enough? 26 ©2016 Apigee. All Rights Reserved. Isolation/Coverage
  • 27.
    API Proxy Testing– Integration test enough? 27 ©2016 Apigee. All Rights Reserved. Test Runner Apigee Target Systems 3rd Party Service Callouts? Async? Complex code?
  • 28.
    Unit Testing –Other benefits •  Code can be tested locally without deployment to Apigee first •  Much faster than integration testing •  Can create hooks to enforce testing during commit 28 ©2016 Apigee. All Rights Reserved.
  • 29.
    Unit Testing –Boundary Principal 29 ©2016 Apigee. All Rights Reserved. Test within your boundaries – don’t test libraries you don’t control
  • 30.
    Unit Testing –Tooling 30 ©2016 Apigee. All Rights Reserved.
  • 31.
  • 32.