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
210
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
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.4k
An Explanation of HTTPS for the Inexperienced
johnbillion
0
1.7k
The A to Z of WordPress Multisite
johnbillion
3
2.2k
A Deep Dive into the Roles and Capabilities API
johnbillion
3
2.8k
A Layout Customiser for The Sun
johnbillion
4
460
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
地域 SRE コミュニティ最前線 / SRE NEXT 2026 Discussion Night Track C
muziyoshiz
0
210
Gen3R: 3D Scene Generation Meets Feed-Forward Reconstruction
spatial_ai_network
0
110
AIに「使われる」時代のSaaS戦略 〜既存WebAPIのMCPサーバー化における開発ノウハウ〜
ekispert_api
0
310
実装だけじゃない! CCA-F取得エンジニアが教えるClaude Code開発プロセス活用術
diggymo
2
510
なぜ人は自分のプロジェクトを 「なんちゃってアジャイル」と 自嘲するのか
kozotaira
0
280
ローカルLLMとLINE Botの組み合わせ その3 / LINE DC Generative AI Meetup #8
you
PRO
0
130
なぜ私たちのSREプラクティスはなかなか機能しないのか 〜システムより先に組織を見る〜 / Why our SRE practices aren't really working
vtryo
3
3.5k
デジタル・デザイン構想 by Sayaka Ishizuka
y150saya
0
200
AWS Summit の片隅で、体育座りしながらコミュニティがにぎわう理由を考えた
k_adachi_01
2
370
AI駆動開発におけるQAエンジニアの役割事例 〜AI駆動開発の現場から〜
kobayashiyorimitsu
0
480
AIと共生する開発者プラットフォーム:バクラクのモノレポ×マイクロサービス基盤
sakajunquality
2
3.3k
AI時代のエンジニアキャリアについて今一度考える
sakamoto_582
2
1.5k
Featured
See All Featured
Making Projects Easy
brettharned
120
6.7k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
360
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
280
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
4 Signs Your Business is Dying
shpigford
187
22k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
ラッコキーワード サービス紹介資料
rakko
1
3.9M
Context Engineering - Making Every Token Count
addyosmani
9
1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
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