Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Unit Testing: What? Why? How?
Search
John Blackbourn
February 14, 2017
Technology
0
180
Unit Testing: What? Why? How?
Slides from my talk at WP Hooked, February 2017.
https://www.meetup.com/wp_hooked/
John Blackbourn
February 14, 2017
Tweet
Share
More Decks by John Blackbourn
See All by John Blackbourn
Investigating Regressions Quickly using Git Bisect
johnbillion
1
2.1k
WP CLI: An Intro and Interesting Use Cases
johnbillion
0
2k
Zen Mode: Developing While You're Offline
johnbillion
3
2.3k
An Explanation of HTTPS for the Inexperienced
johnbillion
0
1.6k
The A to Z of WordPress Multisite
johnbillion
3
2.1k
A Deep Dive into the Roles and Capabilities API
johnbillion
3
2.7k
A Layout Customiser for The Sun
johnbillion
4
430
Debugging as a Key Skill - WCSOF - WCMIL
johnbillion
1
1.9k
An Introduction to Character Encoding - WCNO - WCNL
johnbillion
0
2.1k
Other Decks in Technology
See All in Technology
マルチドライブアーキテクチャ: 複数の駆動力でプロダクトを前進させる
knih
0
9.7k
現地速報!Microsoft Ignite 2025 M365 Copilotアップデートレポート
kasada
2
1.7k
"'TSのAPI型安全”の対価は誰が払う?不公平なスキーマ駆動に終止符を打つハイブリッド戦略
hal_spidernight
0
120
LINEスキマニ/LINEバイトにおけるバックエンド開発
lycorptech_jp
PRO
0
370
自然言語でAPI作業を片付ける!「Postman Agent Mode」
nagix
0
130
Pandocでmd→pptx便利すぎワロタwww
meow_noisy
2
910
DDD x Microservice Architecture : Findy Architecture Conf 2025
syobochim
12
4.2k
AI エージェントを評価するための温故知新と Spec Driven Evaluation
icoxfog417
PRO
2
700
変わるもの、変わらないもの :OSSアーキテクチャで実現する持続可能なシステム
gree_tech
PRO
0
440
レガシーシステム刷新における TypeSpec スキーマ駆動開発のすゝめ
tsukuha
3
670
信頼性が求められる業務のAIAgentのアーキテクチャ設計の勘所と課題
miyatakoji
0
150
メッセージ駆動が可能にする結合の最適化
j5ik2o
9
1.5k
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1032
470k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.8k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
340
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The World Runs on Bad Software
bkeepers
PRO
72
12k
The Pragmatic Product Professional
lauravandoore
36
7k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
We Have a Design System, Now What?
morganepeng
54
7.9k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Mobile First: as difficult as doing things right
swwweet
225
10k
Transcript
Unit Testing: What? Why? How?
John Blackbourn WordPress core developer Working with WordPress for 10+
years Senior Engineer at Human Made @johnbillion
Unit Testing: What? Why? How?
You’re Going to L VE Unit Testing
That’s Enough of That
Unit Testing: What? Why? How?
A unit test is a piece of code which exists
only to verify expectations about the behaviour of another piece of code Verification
a.k.a. “Does my function do what I expect it to
do?”
A unit test operates in isolation in order to avoid
external interference Isolated
Tests typically run on the command line CLI
Tests are highly efficient because they're quickly repeatable Automated
Crossing your fingers and hoping… is not a unit test
Unit Testing: What? Why? How?
A unit test can cover many scenarios and never misses
anything Accuracy
Unit tests give you increased assurance that changes are less
likely to cause breakage Assurance
Unit tests give you confidence to make changes Confidence
Unit tests help you write better code Smaller functions Separation
of concerns Quality
Unit tests can be liberating Clarity
Unit Testing: What? Why? How?
None
None
None
None
“But I know that false isn’t true”
None
Arrange Act Assert AAA
Each time a WordPress test runs, it operates on a
fresh installation Remember
None
None
None
None
Accuracy Assurance Confidence Quality?… The Result
Assertions assertTrue( $actual ) assertFalse( $actual ) assertEquals( $expected, $actual
) assertCount( $expected, $actual ) assertObjectHasAttribute( $key, $actual ) assertArrayHasKey( $key, $actual ) assertWPError( $actual ) assertCanonical( $actual, $expected )
a.k.a. A Real World Gotcha Type Juggling Kills Me
None
None
WUT
None
Provide Verification Isolated Automated Recap
Accuracy Assurance Confidence Quality Recap
Arrange Act Assert Recap
I Hope You’ll Fall In L VE With Testing
Read the WordPress Unit Tests Visit PHPUnit website for reference
Check out WP-CLI scaffolding What Next?
John Blackbourn @johnbillion