API VIRTUALIZATION:
MOCKING ON STEROIDS
Why virtualize your
APIs?
Bootstrap development
Virtual API
Generate
from spec or
with tools
Client Development
Test Design
Integration Development
Isolate components in dev and test
Component in
dev or test
Test Execution
(automated or manual)
3rd party APIs
(virtualized)
Other APIs
(virtualized)
Legacy Systems
(virtualized)
Development
• Simulate (un)expected behavior
• Minimize impact on and usage of external systems
• Assert usage of external components
Enable API evolution… Corp
Corp
Web
app
Corp
App +
API
API
API
API
Device
APP
API
Device
IoT
Device
IoT
Device
API
API
API
Hardware /
Software
Solution
Provide Sandbox
API Virtual API
Evaluate
Integrate
Integration Test
Performance Testing
Solution
under test
Load Test Execution
(automated or manual)
3rd party APIs
(virtualized)
Other APIs
(virtualized)
Legacy Systems
(virtualized)
• Simulate (un)expected performance in external systems
• Minimize impact on and usage of external systems
• Triage Performance bottlenecks
3 levels of API Virtualization
Static
Mocking
Dynamic
Mocking
Virtualize
Static and Dynamic Mocking
Static Mocking
 Static responses
– Semantically correct
– No logic
– Payloads generated from
schemas or examples
 Code or generated from metadata
 Usage: Client and Test
development
Dynamic Mocking
 Dynamic responses
– Based on input
– Re-use input in output
– Scripting
– Data-driven / Data-generation
– Simulate state
 Assertions on incoming content
 Usage: Scenario Testing,
Development
API Virtualization
 Runtime behavior simulation
 Runtime management
– Redirect traffic to Virtual APIs dynamically
– Access control
– Deployment
– Test execution integration
 Usage: Integration / Scenario Testing, Load
Testing, Development
Creation
Refine with dedicated tooling
 Add complex logic for request dispatching
 Add data-driven payloads
 Simulate non-functional behavior
 Add assertions for validating requests
 Pass-through to actual APIs as appropriate
A selection of tools
 Script / code based
– WireMock, JustMock, MockServer, etc.
 SaaS based
– Mocky.io, mockable.io, Runscope
– Part of design tools; Apiary, API Designer (Mulesoft)
 Desktop / Standalone
– Free: SoapUI (does REST too!), WireMock
– Commercial: Ready! API, Soatest, ITKO-Lisa
Virtualising Async APIs
 Domains
– Web: Webhooks, Async SOAP, Websockets
– Legacy: JMS, MQSeries, etc
– IoT protocols: MQTT, AMQP, XMPP, etc
 Virtualization Needs
– Simulate both sender and receiver of events
– Coordinate decoupled message flows / transactions
– Simulate both functional and non-functional behaviour
 Challenging to coordinate orchestrated components
Considerations
 How will virtual APIs be used and managed
– Local / Team / Enterprise
 Technical proficiency of maintainees
– Scripting / coding requirements
– Easy to create new configurations
 CI-Integration
– How redirect API calls to virtualized APIs
 Access control (internal / external)
 Reporting and Governance
API Virtualization – do you need it?
 Local development and basic component testing –>
Probably not
 For providing Sandbox environments -> Maybe
 Collaborative evolution and testing of APIs with low number
of controlled dependencies -> Maybe
 The same – but with high number of complex dependencies
-> Probably
 For simulating both functional and non-functional behavior in
complex distributed API-based solutions -> Definitely
API Virtualization – do you need it?
• Local development & basic component testing
• Requirement for sandbox environment(s)
• Collaborative evolution & testing of APIs with low number of
controlled dependencies
Maybe
• Collaborative evolution & testing of APIs with high number of
complex dependencies
Probably
• Need for simulating functional & non-functional behavior in
complex distributed solutions
Definitely
Thank you
 @olensmar
 ole.lensmar@smartbear.com
 @APIsUncensored / apisuncensored.io

API Virtualization: Mocking on Steroids

  • 1.
  • 2.
  • 3.
    Bootstrap development Virtual API Generate fromspec or with tools Client Development Test Design Integration Development
  • 4.
    Isolate components indev and test Component in dev or test Test Execution (automated or manual) 3rd party APIs (virtualized) Other APIs (virtualized) Legacy Systems (virtualized) Development • Simulate (un)expected behavior • Minimize impact on and usage of external systems • Assert usage of external components
  • 5.
    Enable API evolution…Corp Corp Web app Corp App + API API API API Device APP API Device IoT Device IoT Device API API API
  • 6.
    Hardware / Software Solution Provide Sandbox APIVirtual API Evaluate Integrate Integration Test
  • 7.
    Performance Testing Solution under test LoadTest Execution (automated or manual) 3rd party APIs (virtualized) Other APIs (virtualized) Legacy Systems (virtualized) • Simulate (un)expected performance in external systems • Minimize impact on and usage of external systems • Triage Performance bottlenecks
  • 8.
    3 levels ofAPI Virtualization Static Mocking Dynamic Mocking Virtualize
  • 9.
    Static and DynamicMocking Static Mocking  Static responses – Semantically correct – No logic – Payloads generated from schemas or examples  Code or generated from metadata  Usage: Client and Test development Dynamic Mocking  Dynamic responses – Based on input – Re-use input in output – Scripting – Data-driven / Data-generation – Simulate state  Assertions on incoming content  Usage: Scenario Testing, Development
  • 10.
    API Virtualization  Runtimebehavior simulation  Runtime management – Redirect traffic to Virtual APIs dynamically – Access control – Deployment – Test execution integration  Usage: Integration / Scenario Testing, Load Testing, Development
  • 11.
  • 13.
    Refine with dedicatedtooling  Add complex logic for request dispatching  Add data-driven payloads  Simulate non-functional behavior  Add assertions for validating requests  Pass-through to actual APIs as appropriate
  • 14.
    A selection oftools  Script / code based – WireMock, JustMock, MockServer, etc.  SaaS based – Mocky.io, mockable.io, Runscope – Part of design tools; Apiary, API Designer (Mulesoft)  Desktop / Standalone – Free: SoapUI (does REST too!), WireMock – Commercial: Ready! API, Soatest, ITKO-Lisa
  • 15.
    Virtualising Async APIs Domains – Web: Webhooks, Async SOAP, Websockets – Legacy: JMS, MQSeries, etc – IoT protocols: MQTT, AMQP, XMPP, etc  Virtualization Needs – Simulate both sender and receiver of events – Coordinate decoupled message flows / transactions – Simulate both functional and non-functional behaviour  Challenging to coordinate orchestrated components
  • 16.
    Considerations  How willvirtual APIs be used and managed – Local / Team / Enterprise  Technical proficiency of maintainees – Scripting / coding requirements – Easy to create new configurations  CI-Integration – How redirect API calls to virtualized APIs  Access control (internal / external)  Reporting and Governance
  • 17.
    API Virtualization –do you need it?  Local development and basic component testing –> Probably not  For providing Sandbox environments -> Maybe  Collaborative evolution and testing of APIs with low number of controlled dependencies -> Maybe  The same – but with high number of complex dependencies -> Probably  For simulating both functional and non-functional behavior in complex distributed API-based solutions -> Definitely
  • 18.
    API Virtualization –do you need it? • Local development & basic component testing • Requirement for sandbox environment(s) • Collaborative evolution & testing of APIs with low number of controlled dependencies Maybe • Collaborative evolution & testing of APIs with high number of complex dependencies Probably • Need for simulating functional & non-functional behavior in complex distributed solutions Definitely
  • 19.
    Thank you  @olensmar ole.lensmar@smartbear.com  @APIsUncensored / apisuncensored.io

Editor's Notes

  • #4 Enable client development Enable test design Remove dependencies
  • #5 Functional misbehavings Functional Errors Network errors / Latency Network bandwidth Slow/fast response times
  • #7 For evaluating different aspects of and API For testing integrations For simulating hardware
  • #8 Simulate performance in the Mock itself Simulate/model system / network behaviour Triage performance issues