Is Your API
Misbehaving?
D. Keith Casey Jr
[email protected]
@CaseySoftware
Slide 2
Slide 2 text
Who am I?
Slide 3
Slide 3 text
Who am I?
Clarify.io -
The API for businesses
to build apps that
Search and Understand
their Audio & Videos
Slide 4
Slide 4 text
Who am I?
http://TheAPIDesignBook.com
Slide 5
Slide 5 text
• Assumptions
• The Problem
• Enter BDD
• BDD in Practice
• BDD at Scale
• Next steps…
Slide 6
Slide 6 text
• Assumptions
• The Problem
• Enter BDD
• BDD in Practice
• BDD at Scale
• Next steps…
Slide 7
Slide 7 text
Assumptions
• You have a technical background
• APIs are an important part of your job
• Use them on a regular basis
• Potentially build them too
• Sometimes public, sometimes private
7
Slide 8
Slide 8 text
Assumptions
• Nothing is perfect
• You make mistakes
• Your providers make mistakes
• That other team are knuckleheads
8
Slide 9
Slide 9 text
• Assumptions
• The Problem
• Enter BDD
• BDD in Practice
• BDD at Scale
• Next steps…
Slide 10
Slide 10 text
• Click Tests - someone
• Unit Tests - xUnit suite
• Integration Tests - still probably xUnit
• Web/UI Tests - Selenium, Watir, Testlio (mobile)
API Testing is Deceptive
10
Slide 11
Slide 11 text
… no seriously.
API Testing Sucks
11
Slide 12
Slide 12 text
Two Goals
Prove* that it works (now)
Give us confidence (later)
12
Slide 13
Slide 13 text
Back to the Drawing Board
13
• SMART
• Specific, Measurable, Achievable,
Relevant, and Time-boxed
• INVEST
• Independent, Negotiable, Valuable,
Estimable, Small, Testable
Slide 14
Slide 14 text
• Assumptions
• The Problem
• Enter BDD
• BDD in Practice
• BDD at Scale
• Next steps…
Slide 15
Slide 15 text
BDD - Standard Definition
15
BDD is a synthesis and refinement
of practices stemming from
TDD and ATDD
Slide 16
Slide 16 text
BDD - Dan North
16
BDD is a second-generation, outside-
in, pull-based, multiple-stakeholder,
multiple-scale, high-automation agile
methodology. It describes a cycle
with well-defined outputs, resulting
in the delivery of working, tested
software that matters.
Slide 17
Slide 17 text
BDD - What it really means
17
Get your head out of the system!
Slide 18
Slide 18 text
BDD - What it looks like
18
As a [role], I want [feature]
so that [benefit]
Slide 19
Slide 19 text
BDD - To be more precise
19
It’s English but in the Gherkin syntax so this:
• As a [role], I want [feature] so that [benefit]
becomes a feature (or spec) structured as:
• Given [condition], when I [action] then [result]
Slide 20
Slide 20 text
• Assumptions
• The Problem
• Enter BDD
• BDD in Practice
• BDD at Scale
• Next steps…
At Clarify.io
23
• The first thing everyone does:
• We want to search audio
• We need an API key (use the docs key)
• We need to submit a search query (GET)
• We need to check the results (200 OK)
Slide 24
Slide 24 text
Step 1
24
Write the feature!
Slide 25
Slide 25 text
Step 2
25
Refactor for reuse
(not this time, but usually)
Slide 26
Slide 26 text
Step 3
26
Run the Specs!
Slide 27
Slide 27 text
Step 4
27
Implement our Step
until it passes
Slide 28
Slide 28 text
Step 5
28
Our first challenge: GET
Slide 29
Slide 29 text
Step 6
29
Goto 3
Slide 30
Slide 30 text
At Clarify.io (cont)
30
• The second thing everyone does:
• We want to search our own audio
• We need an API key (use our key)
• We need an audio file
• We need to submit it (POST)
• We need to check the results (201 Created)
Slide 31
Slide 31 text
Step 1
31
Write the feature!
Slide 32
Slide 32 text
Step 2
32
Refactor for reuse
(not this time, but usually)
Slide 33
Slide 33 text
Step 3
33
Run the Specs!
Slide 34
Slide 34 text
Step 4
34
Implement our Step
until it passes
Slide 35
Slide 35 text
Step 5
35
Our first challenge: POST
Slide 36
Slide 36 text
Step 6
36
Goto 3
Slide 37
Slide 37 text
• Assumptions
• The Problem
• Enter BDD
• BDD in Practice
• BDD at Scale
• Next steps…
Slide 38
Slide 38 text
And now what?
38
• Write the feature
• Refactor to reuse steps when possible
• Add the missing bits
• GOAL:
• We should be writing less and less code!
Slide 39
Slide 39 text
Our Status
39
• We validate our helper libraries with this too
• One set of features/specs for the API using:
• the PHP library
• the Ruby Gem
• the Python library (underway)
We’ll launch them publicly soon - https://Github.com/Clarify
Slide 40
Slide 40 text
• Assumptions
• The Problem
• Enter BDD
• BDD in Practice
• BDD at Scale
• Next steps…
Slide 41
Slide 41 text
todo next?
41
Lots of things!
Slide 42
Slide 42 text
D. Keith Casey Jr
[email protected]
@CaseySoftware
Is Your API
Misbehaving?