ScanAPI
Automated Integration Testing and Live Documentation for your API
Camila Maia
1
EuroPython 2020
ScanAPI Automated Integration Testing and Live Documentation for - - PowerPoint PPT Presentation
ScanAPI Automated Integration Testing and Live Documentation for your API Camila Maia EuroPython 2020 1 Motivation Everything started in a week which I as Firefighter 2 I work at... 3 Who am I? - Brazilian Backend
ScanAPI
Automated Integration Testing and Live Documentation for your API
Camila Maia
1
EuroPython 2020
Motivation
Everything started in a week which I as Firefighter 🔦
2
I work at...
3
Who am I?
4
Motivation
Everything started in a week which I as Firefighter 🔦
5
Motivation
Integration Errors 💦
6
different than what’s expected
different than what’s expected
Motivation
Outdated documentation 📝
7
Motivation
Hard to recreate scenarios 😥
8
/reserve/:seat_id flight_id? airplane_id? passenger_id? Is the airplane available? ????
Motivation
Hard to recreate scenarios 😥
9
Proposal
11
1. Provide a Live Documentation 2. Tool to implement integration tests
PokéAPI: https://pokeapi.co $ http https://pokeapi.co/api/v2/pokemon/
How does it work?
Example: PokéAPI
12
13
14
How does it work?
Example: PokéAPI
15
Installing: $ pip install scanapi
# api.yaml api: endpoints:
path: https://pokeapi.co/api/v2/ endpoints:
path: pokemon requests:
method: get path: /
How does it work?
Example: PokéAPI
16
How does it work?
Example: PokéAPI
17
Running
How does it work?
Documentation 📅
18
19
20
21
How does it work?
Integration tests ✅
22 ... requests:
method: get path: / tests:
assert: ${{ response.status_code == 200 }}
assert: ${{ response.elapsed.total_seconds() < 0.5 }}
https://requests.readthedocs.io
assert: ${{ response.json()["count"] == 964 }}
23
How does it work?
Chaining Requests ⛓
24
How does it work?
Chaining requests ⛓
25 requests:
path: pokemon requests:
method: get path: / vars: pokemon_name: ${{ response.json()["results"][0]["name"] }} tests: ...
pokemon/${pokemon_name}
method: get path: ${pokemon_name}
26
Adding ScanAPI to a project
27
Adding ScanAPI to a project
28
... scanapi: docker:
camilamaia/scanapi:1.0.5 steps:
name: Run ScanAPI command: | scanapi scanapi/api.yaml
path: scanapi/report.html
29
name: build-push-staging env: staging requires:
filters: branches:
workflows: version: 2 main: jobs:
filters: branches:
How does it work?
And there is more 🎊
30
Can I start using it?
For sure! 👎
31
scanapi.dev
32
Next Steps
What about the future? 🔯
33
And what if….
Why to contribute?
Join us! 🚁
34
Why to contribute?
Join us! 🚁
35 How Open Source Changed My Life with Max Stoiber
Sprint Session
36
weekend - July 25th and 26th (free!) #sprint-scanapi More information
github.com/scanapi ⭐
37
We are hiring!
Loadsmart
38
Direct Link
THANK YOU
@cmaiacd camilamaia
#talk-scanapi #sprint-scanapi