Category Partitioning:
Introducing TDD Through
Automation and Analysis
Slide 2
Slide 2 text
Hello!
Michael Migliacio
マイケル ミグラシオ
Software Engineering Coach
Slide 3
Slide 3 text
小打も積もれば大木を倒す
Little strokes fell great oaks...
1
Slide 4
Slide 4 text
Let’s Talk TDD
● Testing methodology in which
requirements are analyzed and
turned into test cases before
code is written.
● The code is then written to make
the tests pass.
Slide 5
Slide 5 text
TDD Cycle
Refactor!
Tests may
break.
Test is
failing!
Test is
passing!
Slide 6
Slide 6 text
Benefits of TDD
● Requirements are understood
fully, leading to higher quality
code.
● Tests will exist for each
implemented feature, increasing
developer confidence (vital for
CI/CD).
● Good design is required up front.
Slide 7
Slide 7 text
Challenges in TDD
● Requirements analysis can lead
to paralysis on what to test /
how to test it.
● Lots of time/cognitive load spent
up-front on test design.
● Intimidating for development
teams or teams working in new
domains.
Slide 8
Slide 8 text
CATEGORY PARTITIONING
METHOD
Let’s do this!
2
Slide 9
Slide 9 text
Category Partitioning
● Developed by T.J. Ostrand and
M.J. Balcer in 1988 (before TDD
was commonplace)!
● Focuses on analyzing system
specifications based on
requirements, and translating
them into test cases via
automation.
Slide 10
Slide 10 text
Example Application!
Basic API for conference
attendee data.
Slide 11
Slide 11 text
System Specification
● System specification contains
details about the system.
● First step is to break this down
into functional units.
● This maps nicely to individual
endpoints...
Slide 12
Slide 12 text
Functional Unit
Slide 13
Slide 13 text
Parameters
● Input into functional unit. Maps
directly to endpoint parameters!
● One example: value of {id}.
Slide 14
Slide 14 text
Environments
● Characteristics of system state.
● Examples include: state of
database, system availability
Slide 15
Slide 15 text
Flow of C.P. Method
Test
Specification
(categories,
choices,
constraints)
Test Frames
(automatically
generated)
Test Scripts
(describe
test frames
in code)
Slide 16
Slide 16 text
Categories
● Major properties or
characteristics
● Examples include: format of {id}
parameter, presence in database,
status of database.
Slide 17
Slide 17 text
Choices
● Potential values of each
category.
● Examples include: whether the
value of {id} is properly
formatted, whether the database
is available, whether the id is
present in the database.
Slide 18
Slide 18 text
Example Test Spec
Format of Id:
● Valid format
● Invalid format
Id present in Database:
● Yes
● No
Database Status:
● Available
● Unavailable
Slide 19
Slide 19 text
Constraints
● Restrictions on choices.
● Automated tool will pair up all
choices and generate a maximum
number of test frames.
● We don’t need to test valid id
input if database is down.
● See the problem? Need to reduce
them.
Slide 20
Slide 20 text
Example Test Spec
Format of Id:
● Valid format [property formatValid]
● Invalid format [single]
Id present in Database:
● Yes [if formatValid]
● No [if formatValid]
Database Status:
● Available
● Unavailable [error]
Slide 21
Slide 21 text
Test Frame Generation
● Done via automated tool
● Syntax covered in
demonstration.
● https://github.com/alexorso/tslg
enerator
Slide 22
Slide 22 text
DEMO
Let’s try category partitioning on a simple file encoder!
3
Slide 23
Slide 23 text
◇ There are no stupid ones…
◇ Follow @AngstyGaijin on Twitter if you want to know more.
4 QUESTIONS