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
Beyond Testing
Search
Michael Bodnarchuk
September 15, 2015
Programming
0
48
Beyond Testing
Things you should know maintaining stable testing suite
Michael Bodnarchuk
September 15, 2015
Tweet
Share
More Decks by Michael Bodnarchuk
See All by Michael Bodnarchuk
Codeception 3.0: Long Bloody Story
davert
0
90
DESIGN DECISIONS FOR PERFECT JS E2E TESTING FRAMEWORK
davert
0
680
Bugira
davert
0
59
CodeceptJS Workshop
davert
1
120
Designing Tests Architecture That Does Not Suck
davert
1
190
Beyond Testing
davert
1
360
Beyond Testing for DutchPHP
davert
0
230
Особенности тестирования PHP проектов
davert
0
66
BeTesting
davert
1
120
Other Decks in Programming
See All in Programming
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
Remix on Hono on Cloudflare Workers
yusukebe
1
280
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
890
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
190
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
CSC509 Lecture 11
javiergs
PRO
0
180
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
KATA
mclloyd
29
14k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Invisible Side of Design
smashingmag
298
50k
Practical Orchestrator
shlominoach
186
10k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
What's new in Ruby 2.0
geeforr
343
31k
4 Signs Your Business is Dying
shpigford
180
21k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Rails Girls Zürich Keynote
gr2m
94
13k
Transcript
Michael Bodnarchuk BEYOND TESTING
WHO AM I • Michael Bodnarchuk @davert • Web-developer from
Kyiv, Ukraine • Lead developer of Codeception testing framework and other OS tools like: Robo, AspectMock, etc
WHAT IS IT ALL ABOUT • What to do when
PHPUnit is installed and first tests are done • What you should know writing a test • Choosing the best tool for testing • Creating test environment
KINDS OF TESTS • Acceptance • Functional • Integration •
Unit
BEST PRACTICES SOME KIND OF
IDEAL TEST ▪Condition (Given) ▪Action (When) ▪Assertion (Then)
HOW TO WRITE TEST • Separate configuration from test •
Do not use hierarchy for testcases (use traits when needed) • Separate test code from support code • Make test simple and verbose
DON'T DO IT THIS WAY move to configuration use traits
IMPLEMENT YOUR OWN ASSERTIONS custom assertions make code more readable
MAKE IT SIMPLER!
WHAT IS HARD TO TEST • Asynchronous stuff • Remote
Services • Real Data
TESTS CRITERIA • Execution Stability ↓ • Stability to Changes
↑ • Speed ↓ • Coverage ↑ • Preciseness ↓ • Readability ↕ Unit => Integration => Functional => Acceptance
PRICE OF A FAULT REGRESSION TESTS
DATA MANAGEMENT HOW TO TEST DB INTERACTION
MANAGING TEST DATA WITH • Fixtures (nelmio/alice) • Dumps •
Factories (thephpleague/factory-muffin)
FACTORY_MUFFIN IN REAL LIFE
DATA CLEANUP STRATEGIES • Manually create/delete data between tests •
Recreate the database between tests • Using transactions – reverting changes with rollback
TOOLS FOR TESTING YOU SHOULD PROBABLY KNOW
PHPUNIT • Standard de-facto • Monolithic framework • Two mocking
engines included (why not 3?) • JUnit, HTML, reports... and codecoverage • And other 100500 sometimes used features
PHPSPEC • TDD framework • Classes are generated from tests
• Dependencies are described through mocking • Does not replace PHPUnit • For development, not for testing
BEHAT • BDD-framework • Ubiquitous language (Gherkin) • Acceptance testing
via Mink (Selenium, Goutte, etc)
CODECEPTION • BDD-style testing framework • Scenario DSL for describing
tests • Over 20 modules to cover the most of possible cases • Testing via Selenium, PhpBrowser, frameworks...
TESTING EMAILS: MAILCATCHER
MAILCATCHER • Ruby application with web interface • SMTP-mock •
Provides REST API for sent emails • API can be used in tests • Alternative in Go - MailHog
TESTING WEB APPLICATIONS • Selenium • PhantomJS • Browser emulation
via HTTP client
USING SELENIUM ON CI SERVER • Selenium Server • Xvfb
– Virtual Framebuffer • Firefox or Chromium
INSTEAD OF CONFIGURING IT MANUALLY docker run -d -p 4444:4444
-e APP_HOST=myapp davert/selenium-env
WHAT IS DOCKER? • Docker is an open platform distributed
apps • Runs and manages isolated Linux containers • Provides GitHub-like infrastructure
PARALLEL TESTING • Tests separation • Jobs isolation
HOW TO PARALLEL TESTS WITH DOCKER • Build container(s) for
test environment • Run container(s) with Docker Compose • Use Jenkins Matrix to run concurrent builds
docker run -i -t -v $WORKSPACE:/project test_container ./runtests.sh $SUITE
CONCLUSIONS • Testing is not just about unit tests •
Tests are code: make them easy to read and maintain • Testing is about tools, environment and infrastructure as well
QUESTIONS? • My name is Michael Bodnarchuk • Twitter: @davert
• GitHub: DavertMik • ….and don't forget to try http://codeception.com