Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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.2k
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
Ruby で作る大規模イベントネットワーク構築・運用支援システム TTDB
taketo1113
1
210
生成AI・AIエージェント時代、データサイエンティストは何をする人なのか?そして、今学生であるあなたは何を学ぶべきか?
kuri8ive
2
2.1k
品質のための共通認識
kakehashi
PRO
3
220
[デモです] NotebookLM で作ったスライドの例
kongmingstrap
0
100
最近のLinux普段づかいWaylandデスクトップ元年
penguin2716
1
670
MapKitとオープンデータで実現する地図情報の拡張と可視化
zozotech
PRO
1
120
コミューンのデータ分析AIエージェント「Community Sage」の紹介
fufufukakaka
0
440
Playwrightのソースコードに見る、自動テストを自動で書く技術
yusukeiwaki
13
5k
【CEDEC+KYUSHU2025】学生・若手必見!テクニカルアーティスト 大全 ~仕事・スキル・キャリアパス、TAの「わからない」を徹底解剖~
cygames
PRO
0
150
AI駆動開発における設計思想 認知負荷を下げるフロントエンドアーキテクチャ/ 20251211 Teppei Hanai
shift_evolve
PRO
2
190
プロダクトマネージャーが押さえておくべき、ソフトウェア資産とAIエージェント投資効果 / pmconf2025
i35_267
2
590
[CMU-DB-2025FALL] Apache Fluss - A Streaming Storage for Real-Time Lakehouse
jark
0
110
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
KATA
mclloyd
PRO
32
15k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
390
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
Building Adaptive Systems
keathley
44
2.9k
4 Signs Your Business is Dying
shpigford
186
22k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.8k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
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