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
Let's make this test suite run faster! - BeJUG
Search
dgageot
April 05, 2012
Programming
1
510
Let's make this test suite run faster! - BeJUG
dgageot
April 05, 2012
Tweet
Share
More Decks by dgageot
See All by dgageot
Docker on Google Cloud Platform
dgageot
0
1.6k
Lightning Talk Mix-IT 2014
dgageot
0
790
CodeStory 2013 "La Selection Finale"
dgageot
0
750
Finale Code Story
dgageot
1
700
Le facilitateur, un rôle encore méconnu
dgageot
1
190
Mockito. Ecrire des tests unitaires est devenu simple.
dgageot
2
410
Git, la gestion de configuration qui vous veut du bien
dgageot
1
400
My own preferred testing techniques
dgageot
1
100
Let's make this test suite run faster
dgageot
1
53
Other Decks in Programming
See All in Programming
Go言語でターミナルフレンドリーなAIコマンド、afaを作った/fukuokago20_afa
monochromegane
2
140
推し活としてのrails new/oshikatsu_ha_iizo
sakahukamaki
3
1.7k
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
150
開発効率向上のためのリファクタリングの一歩目の選択肢 ~コード分割~ / JJUG CCC 2024 Fall
ryounasso
0
360
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.1k
CPython 인터프리터 구조 파헤치기 - PyCon Korea 24
kennethanceyer
0
240
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
23k
CSC305 Lecture 13
javiergs
PRO
0
130
カスタムしながら理解するGraphQL Connection
yanagii
1
1.2k
Why Spring Matters to Jakarta EE - and Vice Versa
ivargrimstad
0
970
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
230
RailsのPull requestsのレビューの時に私が考えていること
yahonda
5
1.7k
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
Code Reviewing Like a Champion
maltzj
519
39k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
37
1.8k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
4 Signs Your Business is Dying
shpigford
180
21k
Building Applications with DynamoDB
mza
90
6.1k
It's Worth the Effort
3n
183
27k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
3
370
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.4k
Transcript
Let's make this test suite run faster!
David Gageot Freelance developer @dgageot javabien.net
Why make a test suite run faster?
“ I firmly believe it can make your product better.
Faster to test leads to faster to write, deploy and use ” Anonymous bearded freelance developper
You test early and often. Right?
Continuous integration?
Continuous testing?
Continuous deployment?
Testing a lot can lead to waiting a lot
How wants his coding room to look like
Test suite duration can be contained
Jenkins slaves to the rescue
Jenkins slaves to the rescue. not.
Why complicated when it can be simple?
I’ll share a few easy tricks
“ I firmly believe it can make your product better.
Faster to test leads to faster to write, deploy and use ” Anonymous bearded freelance developper
How can we accelerate the tests? The Cheater The Lazy
The Cheater
Buy a faster machine. Tests are cpu/
Thank you Q/A
BUT single threaded tests get slower 0 25 50 75
100 2007 2008 2009 2010
Use all the cores with Maven3 mvn -T1 clean install
: 5:05s mvn -T4 clean install : 3:10s Beware of tests with side effects
It’s not just me
Use all the cores with JUnit/TestNG Beware of tests with
side effects
That’s it for cheaters No silver bullet
The Lazy
Delete useless tests It’s so simple, we don’t do it...
Even better, delete dead code
Even better, delete dead code Leads to deleting even more
useless tests
Work in a sandbox In-memory database H2 behaves much like
MySql As simple as changing an xml file The database is slow
It’s Not only SQL If going for NoSQL, choose a
server that can run in-process eg. Voldemort The network is slow
In-memory SMTP Server SubEtha SMTP
Abstract the filesystem Apache VFS (Virtual File System) Spring Resource...
In-memory everything As a bonus, tests will run smoother
Of course all of these are easier to setup at
the beginning of a project
The
5 minutes a day can make a difference
Don’t test business rules in integration Unit tests are often
a better place
Not the same scale of speed 10sec .01sec
Action #1 - Break the longer integration Into one faster
integration test and a lot of small
Action #2 - Mock the slowest layers Mocks are not
just for unit tests eg. with Spring and Mockito spies
Action #3 - Don’t test through the Selenium is often
overkill «But my application is complex!» «My users want complex features, My users want Ajax» «I need to test browser compatibility!»
Really?
Complexity has a cost That you pay each time tests
run
Test through the browser the strict Unit test Javascript
Action #4 - Sometimes be old school write (easier to
test) server-side code
Thank you Q/A
One more thing™ Action #0 - Simplify and optimize your
code Tests will run faster Keep that one secret...
Thank you Q/A