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
Behat Layered Cake - KaunasPHP
Search
Marek Matulka
January 14, 2015
Programming
2
310
Behat Layered Cake - KaunasPHP
Speed up Behat tests with a clever use of the layered architecture - KaunasPHP meetup edition!
Marek Matulka
January 14, 2015
Tweet
Share
More Decks by Marek Matulka
See All by Marek Matulka
Test Smarter, Not Harder
super_marek
0
65
Super Marek's Testing Strategy (LeedsPHP meetup)
super_marek
1
310
Applying DDD when building Drupal modules using Symfony components (DrupalCamp CS)
super_marek
1
1.2k
Mission (Im)possible: Quality Decoupled Code with Drupal 7 (PHP SW meetup)
super_marek
0
220
Mission (Im)possible: Quality Decoupled Code with Drupal 7 (Singapore PHP user group meetup)
super_marek
0
450
Flying in style without splashing out
super_marek
1
230
Mission (Im)possible: Quality Decoupled Code with Drupal 7 (DrupalCamp Scotland)
super_marek
0
170
Mission (Im)possible: Quality Decoupled Code with Drupal 7
super_marek
0
630
Modernising the Legacy (ZendCon)
super_marek
0
400
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
570
技術的負債の正体を知って向き合う
irof
0
230
品質ワークショップをやってみた
nealle
0
610
その面倒な作業、「Dart」にやらせませんか? Flutter開発者のための業務効率化
yordgenome03
1
140
Reactive Thinking with Signals and the Resource API
manfredsteyer
PRO
0
100
AI Agent 時代的開發者生存指南
eddie
4
2.1k
Range on Rails ―「多重範囲型」という新たな選択肢が、複雑ロジックを劇的にシンプルにしたワケ
rizap_tech
0
6.7k
TransformerからMCPまで(現代AIを理解するための羅針盤)
mickey_kubo
6
3.3k
テーブル定義書の構造化抽出して、生成AIでDWH分析を試してみた / devio2025tokyo
kasacchiful
0
270
SwiftDataを使って10万件のデータを読み書きする
akidon0000
0
240
登壇は dynamic! な営みである / speech is dynamic
da1chi
0
360
デミカツ切り抜きで面倒くさいことはPythonにやらせよう
aokswork3
0
260
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.7k
jQuery: Nuts, Bolts and Bling
dougneiner
65
7.9k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.5k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
The Invisible Side of Design
smashingmag
302
51k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
34
2.3k
Six Lessons from altMBA
skipperchong
29
4k
Code Reviewing Like a Champion
maltzj
526
40k
Site-Speed That Sticks
csswizardry
13
920
Gamification - CAS2011
davidbonilla
81
5.5k
Building Adaptive Systems
keathley
44
2.8k
Transcript
Behat Layered Cake KaunasPHP edition Kaunas, 14 Jan 2015
Labas vakaras!
@super_marek Marek Matulka
at SensioLabsUK Software Engineer
part of Inviqa Group SensioLabsUK
None
a tool that makes BDD possible
With Behat you can...
With Behat you can... ...write human-readable stories that describe behaviour
of your application.
With Behat you can... ...automate testing of your application’s behaviour
with human-readable examples.
With Behat you can... ...change behaviour of your application with
confidence.
None
Typical dev stack - Vagrant VM - Symfony framework -
mysql or mongodb storage - Linux/OS X host - scrutiniser-ci
A project
That’s sloooow!
Should I get a faster computer?
What is the problem?
Where’s the problem? it takes too much time
Where’s the problem? Guest VM
Where’s the problem? MySQL
Where’s the problem? MySQL inside Guest VM
Let’s try it on the host!
A project
(63 scenarios in 320 steps) vs
But!
What if... my project grows and I’ll have 3000+ steps?
What if I had 3000+ steps? 300 steps took over
10 minutes 3000 steps will take over 100 minutes! (inside guest VM)
What if I had 3000+ steps? 300 steps took over
1 minute 3000 steps will take over 10 minutes! (on host)
How to make it faster?
Disable xdebug extension 30-40% improvement
Replace slow modules with... Replace slow DB with fast in-memory
or file-system persistent storage
Example Controller
Example Controller
(short introduction to) Layered Architecture
Layered Architecture User Interface Application Domain Infrastructure
Dependency Inversion “High level modules should not depend on lower
level implementation” – Good old Uncle Bob
Dependency Inversion Policy Layer <interface> Policy Service Mechanism Layer <interface>
Mechanism Service Utility Layer
(short introduction to) Hexagonal Architecture
Hexagonal Architecture Browser Logs Database Auth Domain
Hexagonal Architecture UI Adapter Log Adapter Data Storage Adapter External
Data Adapter Domain
Hexagonal Architecture UI Adapter Log Adapter Data Storage Adapter Domain
UI client port log adapter port persistence layer port Data Provider Adapter data provider port
Hexagonal Architecture UI Adapter Log Adapter Test Adapter Test Adapter
Data Storage Adapter Test Adapter Domain External Data Adapter Test Adapter
How to do that?
Repository Interface Acme\Learning\Conference Acme\Learning\ConferenceRepository
Repository Interface Acme\Learning\Conference Acme\Learning\ConferenceRepository Domain Port
Describe Communication
Your controller
Spec Controller to use Interface
Spec Controller to use Interface Port
Implement your repository
Implement your repository Port Adapter
Register repository as a Service!
Add another Adapter
Implement your repository
Implement your repository Port Adapter
Register repository as a Service!
Configure the Test env
Prepare Test Infrastructure config_test.yml:
Configure dependency injection
How fast can it be?
MySql Inside Guest VM
MySql On Host
Mocked Storage Inside Guest VM
Mocked Storage On Host
Things to remember
Hexagonal Architecture UI Adapter Log Adapter Test Adapter Test Adapter
Data Storage Adapter Test Adapter Domain External Data Adapter Test Adapter
Integration tests Don’t forget to test your adapters! Use PhpUnit
for that.
Talk to me after presentation! Demo
Questions?
Thank you! https://speakerdeck.com/super_marek @super_marek