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…
So let’s do this!
https://github.com/caseysoftware/is-your-API-misbehaving *
* I don’t like Github as an organization but didn’t
have time to convert all of this and fully test it
with Gitlab which is a better product and company.
Slide 24
Slide 24 text
Using Github…
24
• Let’s start with search
• Write the story
• Add the stubbed methods
• Write the methods
• Validate the results
• simple-search-step-{n}-{description}
Slide 25
Slide 25 text
Using Github…
25
• Now, let’s get the issues for a repository
• Write the story
• Add the stubbed methods
• Write the methods
• Validate the results
• issues-list-step-{n}-{description}
Slide 26
Slide 26 text
Using Github…
26
• Now, let’s get all of your repositories
• Write the story
• Add the stubbed methods
• Write the methods
• Validate the results
• authentication
• myrepos-step-{n}-{description}
Slide 27
Slide 27 text
Using Github…
27
• Now, let’s watch a repository
• Write the story
• Add the stubbed methods
• Write the methods
• Validate the results
• watch-repo-step-{n}-{description}
Slide 28
Slide 28 text
Using Github…
28
• Now, let’s fork a repository
• Write the story
• Add the stubbed methods
• Write the methods
• Validate the results
• watch-repo-fork-step-{n}-{description}
Slide 29
Slide 29 text
Using Github…
29
• Now, let’s create a repository
• Write the story
• Add the stubbed methods
• Write the methods
• Validate the results
• create-repo-step-{n}-{description}
Slide 30
Slide 30 text
• Assumptions
• The Problem
• Enter BDD
• BDD in Practice
• BDD at Scale
• Next steps…
Slide 31
Slide 31 text
And now what?
31
• Write the feature
• Refactor to reuse steps when possible
• Add the missing bits
• GOAL:
• We should be writing less and less code!
Slide 32
Slide 32 text
Next Steps?
32
• We can validate other helper libraries too
• One set of features/specs for the API using:
• the PHP library
• the Ruby Gem
• the Python library
Slide 33
Slide 33 text
• Assumptions
• The Problem
• Enter BDD
• BDD in Practice
• BDD at Scale
• Next steps…
Slide 34
Slide 34 text
todo next?
34
Lots of things!
Slide 35
Slide 35 text
todo next?
35
But remember:
Start small and iterate!
Slide 36
Slide 36 text
D. Keith Casey Jr
[email protected]
@CaseySoftware
Is Your API
Misbehaving?