SlideShare a Scribd company logo
1 of 83
Download to read offline
Variety of automated tests
Artjom Kurapov
Kurapov.ee	
  
@tot_ra	
  
10	
  years	
  in	
  IT	
  /	
  PHP	
  
lvl	
  65	
  elf/hunter	
  
Developer	
  QA	
  engineer	
  
Fear	
  of	
  sudden	
  death	
  
REALITY
IS COMPLEX
Objectivity - state or quality of being true even
outside of a subject’s individual biases,
interpretations, feelings, and imaginings.
Client – I dropped a phone
Test that it works
Awareness	
  &	
  Clarity	
  
OVERVIEW	
  
MarFn	
  Fowler	
  hHp://marFnfowler.com/arFcles/microservice-­‐tesFng/	
  
WHITE	
  GRAY	
  BLACK	
  
SUBJECTIVE	
  
IMPORTANCE	
  
GITHUB	
  LINKS	
  
TEST	
  FAMILY	
  
PHP testing tools & authors
SebasFan	
  Bergmann	
  
@s_bergmann	
  
atoum/atoum	
  
mlively/Phake	
  
ribozz/PhpSpock	
  
marco-­‐fiset/TesFfy.php	
  
SimpleTest	
  
inclusive-­‐design/AChecker	
  
Ciaran	
  McNulty	
  
@ciaranmcnulty	
  
KonstanFn	
  Kudryashov	
  
@everzet	
  
Michael	
  Bodnarchuk	
  
@davert	
  
LEVEL 1 BLACK BOX
Scenario tests
1	
  
Basic scenario tests
•  Create	
  a	
  feature	
  list	
  
– Register	
  as	
  new	
  user	
  
– Register	
  with	
  coupon	
  
– Login	
  
– Checkout	
  
•  Timeouts	
  between	
  commands	
  
•  Hard-­‐coded	
  data	
  
1	
  
CodecepFon/CodecepFon	
  
giorgiosironi/phpunit-­‐selenium	
  
minkphp/MinkSelenium2Driver	
  
UI testing tools
•  Browser	
  controllers	
  –	
  Selenium,	
  Sahi	
  
•  Headless	
  browsers	
  
– CasperJS,	
  PhantomJS,	
  GouHe	
  
•  Custom	
  stuff	
  -­‐	
  WaFr,	
  TestComplete,	
  iMacros	
  
1	
  
CodecepFon/CodecepFon	
  
giorgiosironi/phpunit-­‐selenium	
  
minkphp/MinkSelenium2Driver	
  
1	
  
Sum	
  of	
  complexity	
  
• Not	
  informaJve	
  if	
  fails	
  
• Environment	
  maintenance	
  
• New	
  tech	
  	
  
– dragging,	
  canvas,	
  svg,	
  	
  
– touch,	
  mulFtouch,	
  3d-­‐touch	
  
1	
  
CodecepFon/CodecepFon	
  
giorgiosironi/phpunit-­‐selenium	
  
minkphp/MinkSelenium2Driver	
  
Instability	
  &	
  non-­‐determinism	
  
• Async	
  -­‐	
  ajax,	
  animaFons,	
  upload	
  
• HTML-­‐dependent	
  
• Hard-­‐coded	
  data	
  &	
  dependent	
  tests	
  
• External	
  websites	
  
• Drivers	
  
1	
  
CodecepFon/CodecepFon	
  
giorgiosironi/phpunit-­‐selenium	
  
minkphp/MinkSelenium2Driver	
  
AbstracFng	
  QA	
  framework	
  
•  Syntax	
  improvement	
  
•  Page	
  objects	
  +	
  Workflows	
  
•  API	
  for	
  data	
  reset	
  /	
  VM	
  per	
  process	
  
•  RepeaFng	
  funcFons	
  
–  Login,	
  Messages	
  
–  Form	
  saving,	
  Layout	
  mode	
  
2	
  
CodecepFon/CodecepFon	
  
giorgiosironi/phpunit-­‐selenium	
  
minkphp/MinkSelenium2Driver	
  
Behaviour	
  tests	
  
• Human-­‐readable	
  specificaFon	
  
• Needs	
  parsing	
  
• Business	
  people-­‐oriented	
  
Behat/Behat	
  
3	
  
3	
  
3	
  
3	
  
Screenshots	
  /	
  CSS	
  regression	
  
Pixel-­‐by-­‐pixel	
  comparison	
  
Similarity	
  in	
  %	
  
imagick::compareImages()	
  
4	
  
Huddle/PhantomCSS	
  
LEVEL 2 GRAY BOX
Environment	
  diagnosFcs	
  
•  RAM	
  /	
  HDD	
  /	
  file	
  permissions	
  
•  Packages,	
  extensions,	
  libraries	
  
•  Services	
  /	
  docker	
  containers	
  
	
  	
  1	
  
 	
  1	
  
 	
  1	
  
IntegraFon	
  external	
  APIs	
  
• Availability	
  -­‐	
  FTP	
  /	
  REST	
  API	
  
– server	
  is	
  down	
  
– no	
  file	
  /	
  API	
  404	
  
• CompaFbility	
  
– empty	
  file	
  
– wrong	
  json/XML	
  schema	
  
	
  	
  2	
  
guzzle/guzzle	
  
CodecepFon/CodecepFon	
  
 	
  2	
  
Frontend / UI
Backend / DB
API
Single	
  Page	
  ApplicaFon	
  
Own	
  internal	
  API	
  
•  HTTP	
  GET	
  on	
  all	
  endpoints	
  
No	
  “Stack	
  trace”,	
  “error”,	
  “excepFon”	
  in	
  response	
  
	
  
•  POST/PUT	
  for	
  data	
  change	
  
– 	
  Mobile	
  app	
  scenarios	
  
– 	
  UDP	
  +	
  binary	
  data	
  
– 	
  Image	
  upload	
  
	
  	
  3	
  
guzzle/guzzle	
  
CodecepFon/CodecepFon	
  
Why	
  you	
  need	
  to	
  test	
  with	
  real	
  DB	
  
•  DB	
  specifics	
  –	
  dates	
  /	
  autoincrements	
  
•  Stored	
  procedures	
  
•  TransacFons	
  
•  Handling	
  large	
  data	
  
•  ORM	
  mapping	
  
	
  	
  3	
  
Internal	
  API	
  +	
  separate	
  DB	
  	
  
•  DB	
  isolaFon	
  for	
  each	
  test	
  
•  Slow	
  &	
  SQL	
  fixtures	
  harder	
  to	
  maintain	
  
•  AlternaFves	
  
–  transacFon	
  &	
  rollback	
  
–  Virtual	
  machine	
  
–  raw	
  db	
  file	
  copy	
  
	
  	
  4	
  
 	
  4	
  
Security + fuzzing tests
Bruteforce	
  own	
  API	
  
•  InjecFons	
  -­‐	
  sql,	
  xss	
  
•  Argument	
  types	
  
– bool,	
  array,	
  string,	
  json	
  
•  Binary/Images	
  
– Different	
  types,	
  sizes	
  
drodil/PHP-­‐Fuzz-­‐tester	
  
	
  	
  5	
  
 	
  5	
  
 	
  5	
  
	
  	
  
 	
  5	
  
 	
  
	
  	
  5	
  
 	
  
	
  	
  5	
  
Performance tests - backend
•  Response	
  Fme	
  <	
  1s	
  
•  DB	
  queries	
  <	
  15	
  
•  Memory	
  load	
  <	
  10MB	
  
•  Is	
  the	
  app	
  geong	
  slower?	
  
	
  	
  6	
  
jokkedk/webgrind	
  
Data integrity/sync tests
•  Check	
  data	
  in	
  N	
  services	
  
– files	
  in	
  Mysql,	
  mongo,	
  AWS	
  
•  JSON	
  schema,	
  NULLs,	
  Dates	
  
Example	
  –	
  translaFons	
  export-­‐import	
  in	
  UTF16	
  CSV	
  
	
  	
  7	
  
Application migration/upgrade tests
•  If	
  you	
  run	
  delta	
  scripts	
  /	
  migraFons	
  (like	
  phinx)	
  
•  MigraFon	
  script	
  =	
  unit	
  tests	
  
•  Data	
  integrity	
  auer	
  run	
  
	
  	
  8	
  
Configuration matrix tests
If	
  you	
  support	
  mulFple	
  environment	
  combinaFons	
  (CMS)	
  
•  Browsers	
  
•  PHP	
  versions	
  
•  Servers	
  
•  OS	
  
Virtualize!	
  –	
  docker,	
  vagrant	
  
4*4*4*4 = 256 variations,
but it can get worse
	
  	
  9	
  
LEVEL 3 WHITE BOX
Unit tests
•  Limited	
  to	
  isolated	
  funcFon	
  or	
  class	
  
•  Data	
  processing	
  confirmaFon	
  
– math	
  /	
  logic	
  /	
  price	
  calculators	
  
– regexp	
  /	
  parsers	
  /	
  validators	
  
– random()	
  raFo	
  
sing()	
  
	
  	
  1	
  
Unit tests of private methods
“you	
  should	
  not	
  test	
  privates,	
  its	
  a	
  bad	
  pracFce”	
  
•  Abstract	
  class	
  
•  Public	
  efficiency	
  /	
  cycles	
  
•  Debug	
  
new	
  ReflectionClass(‘Man’)-­‐>getMethod(‘urinate’)	
  
	
  -­‐>setAccessible(true)	
  
urinate()	
  
	
  	
  1	
  
Unit tests calling private methods
“(In	
  phpspec)	
  you	
  cannot	
  mock	
  system	
  under	
  test.	
  
This	
  is	
  a	
  bad	
  pracFce”	
  
	
  
runkit::method_redefine	
  
urinate()	
  
	
  	
  1	
  
visitBathRoom()	
  
 	
  1	
  
 phpspec	
  describe	
  Gratheon/validators/Phone	
  
	
  	
  1	
  
Unit tests calling other classes
Test	
  doubles:	
  
•  Dummy	
  –	
  argument	
  that’s	
  not	
  used	
  (during	
  test)	
  
•  Stub	
  –	
  hard-­‐coded	
  value	
  
•  Spy	
  –	
  did	
  methods	
  got	
  called?	
  
•  Fake	
  –	
  dynamic	
  stubs	
  
•  Mock	
  –	
  all-­‐in-­‐one	
   padraic/mockery
phpspec/prophecy
Codeception/AspectMock
sebastianbergmann/phpunit-mock-objects
	
  	
  2	
  
Mocks
ExpectaJons	
  of	
  coupling	
  dynamics:	
  
•  What	
  objects/funcFons	
  to	
  be	
  called	
  	
  
•  Order	
  &	
  Fming	
  
•  Arguments	
  
•  Emulates	
  returns	
  
•  ExcepFons	
  
	
  	
  2	
  
padraic/mockery
phpspec/prophecy
Codeception/AspectMock
sebastianbergmann/phpunit-mock-objects
man	
   home	
  
sleep()
Mocks
useBed() protect()
warm()
store()
	
  	
  2	
  
padraic/mockery
phpspec/prophecy
Codeception/AspectMock
sebastianbergmann/phpunit-mock-objects
Mocks – does it call something?
	
  	
  2	
  
man	
   hostel	
  
sleep() useBed()
padraic/mockery
phpspec/prophecy
Codeception/AspectMock
sebastianbergmann/phpunit-mock-objects
 	
  2	
  
+
prophecy
	
  	
  2	
  
Mocks with magic syntax
 	
  2	
  
Mocks chains
 	
  2	
  
Mock magic chains
 	
  2	
  
Mocks – backward thinking
Code	
  
•  Update()	
  
•  Pdo	
  prepare()	
  
•  Statement	
  execute()	
  
•  Statement	
  rowCount()	
  
Test	
  
•  Statement	
  execute()	
  
•  Statement	
  rowCount()	
  
•  Pdo	
  prepare()	
  
•  Update()	
  
Contracts
man	
   wife	
  
tests	
   tests	
  
	
  	
  3	
  
sex()	
  
getNewKid()	
  
Side 1 has expectations
	
  	
  3	
  
man	
  
Perfect	
  
wife	
  
sex_anyTime()	
  
sex_noCondom()	
  
getNewKid_hasMyHair()	
  
sex()	
  
getNewKid()	
  
Side 2 has different expectations
abortKid()
findNewDaddy()
	
  	
  3	
  
Rich	
  
daddy	
  
wife	
  
sex_forPleasure()	
  
getNewKid_auer30()	
  
sex()	
  
getNewKid()	
  
Contracts – a smarter interface
•  Input	
  validaFon	
  
•  Method	
  call	
  sequence	
  
•  Internal	
  state	
  limitaFons	
  
•  Output	
  expectaFons	
  
empty	
  array,	
  false,	
  Null,	
  array,	
  stdClass,	
  Inherited	
  
enFty,	
  id-­‐based	
  map,	
  paginaFon	
  object…	
  
	
  	
  3	
  
Contracts – mock matcher
man	
   wife	
  
	
  	
  3	
  
Contract	
  
Contract tests
ParFes	
  have	
  obligaFons	
  
•  PrecondiFons	
  –	
  before	
  running	
  method	
  
•  PostcondiFons	
  
•  Invariants	
  –	
  limitaFons	
  for	
  the	
  enFre	
  class	
  
lisachenko/php-­‐deal	
  
stuartherbert/ContractLib	
  
	
  	
  3	
  
 	
  3	
  
 	
  3	
  
In-­‐memory	
  filesystem	
  tests	
  
• built-­‐in	
  streaming	
  funcFon	
  support	
  
– file_put_contents,	
  fwrite	
  
• permissions	
  &	
  viewer	
  
• large	
  file	
  support	
  
• result	
  structure	
  asserFon	
  
• relaFve	
  paths	
  are	
  not	
  supported	
  
– chdir(),	
  realpath()	
  too	
  
mikey179/vfsStream	
  
	
  	
  4	
  
 	
  4	
  
In-memory database tests
FuncFon	
  call	
  expected,	
  not	
  enFre	
  stack.	
  Fast,	
  but	
  narrow	
  
	
  
PHPUnit_Extensions_Database_TestCase	
  -­‐	
  too	
  complex	
  
•  Data	
  sources:	
  XML,	
  CSV,	
  mysql	
  dump	
  
•  DB	
  virtualizaFon:	
  PDO	
  +	
  SQLite	
  
See	
  also:	
  H2	
  Database,	
  HyperSQL,	
  Apache	
  Derby	
  
sebasFanbergmann/dbunit	
  
liip/LiipFuncFonalTestBundle	
  
	
  	
  5	
  
 	
  5	
  
Component testing
Component	
  /	
  library	
  -­‐	
  coherent,	
  replaceable	
  uFlity	
  classes	
  
	
  
For	
  example:	
  
-­‐	
  Form	
  builder	
  (please	
  don’t)	
  
-­‐	
  Validator	
  
-­‐	
  Logger	
  
-­‐	
  Tree	
  builder	
  
-­‐	
  Image	
  resizer	
  
-­‐	
  File	
  storage	
  abstracFon	
  
-­‐	
  CSV/XML	
  generator/parser	
  
man	
   wife	
   cat	
  
sofa	
  
sleepOn() clean() destroy()
	
  	
  6	
  
TEST DESIGN
Speed - order by types
PHPUNIT.xml	
  
•  Unit	
  tests	
  
–  General	
  project	
  unit	
  tests	
  (validators,	
  DB	
  adapter)	
  
–  Unit	
  tests	
  per	
  component	
  (models)	
  
•  IntegraFon	
  tests	
  
–  External	
  
–  Internal	
  API	
  
–  Internal	
  with	
  DB	
  isolaFon	
  
–  Performance	
  +	
  Security	
  
–  Data	
  integrity	
  
•  UI	
  tests	
  
–  Screenshoong	
  
Time	
  
Modularity	
  
	
  /controllers/arFcle.php	
  
/models/arFcle.php	
  
/tests/integraFon/arFcleControllerTest.php	
  
/tests/unit/arFcleModelTest.php	
  
	
  
/arFcle/controller/	
  
/article/model/	
  
/article/modelTests/	
  
/article/controllerTests/	
  
Divide	
  your	
  app	
  into	
  modules	
  -­‐	
  see	
  what	
  tests	
  you	
  lack	
  where	
  
Annotations
jump	
  between	
  funcFon	
  and	
  test	
  
@see	
  ArFcleController::postCreate	
  
	
  
@Fcket	
  T-­‐1000	
  +	
  JIRA	
  API	
  
(PHPUnit	
  supports)	
  
	
  
@group	
  producFon	
  
@group	
  failed	
  
phpunit	
  -­‐-­‐testsuite	
  unit	
  
	
  
More than code coverage
Code	
  coverage	
  =	
  you	
  tried	
  to	
  test	
  
Delta	
  coverage	
  –	
  what	
  test	
  adds	
  
	
  
MutaFons	
  help	
  to	
  find	
  	
  
•  tests	
  that	
  lack	
  enough	
  asserts	
  
•  fragile	
  code	
  
henrikbjorn/PhpSpecCodeCoverageExtension	
  
 	
  
padraic/humbug
padraic/mutagenesis
Halleck45/MutaTesting	
  
What else to test?
•  Frontend	
  
•  Stress	
  /	
  Load	
  
•  SQL	
  procedures	
  
•  Accessibility	
  tests	
  
•  GlobalizaFon	
  
Track your mistakes
•  Monitoring	
  tests	
  failures	
  
•  Coverage	
  trend	
  
•  Test	
  quality	
  
Monitoring	
  code	
  health:	
  
•  Complexity	
  
•  Code	
  standard	
  compliance	
  
Block8/PHPCI
Halleck45/PhpMetrics
squizlabs/PHP_CodeSniffer	
  
Awareness	
   Clarity	
  
Tests	
   Architecture	
  
QUESTIONS?

More Related Content

What's hot

Les race conditions, nos très chères amies
Les race conditions, nos très chères amiesLes race conditions, nos très chères amies
Les race conditions, nos très chères amiesPierre Laporte
 
What is the Joomla Framework and why do we need it?
What is the Joomla Framework and why do we need it?What is the Joomla Framework and why do we need it?
What is the Joomla Framework and why do we need it?Rouven Weßling
 
The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7Wim Godden
 
The why and how of moving to php 8
The why and how of moving to php 8The why and how of moving to php 8
The why and how of moving to php 8Wim Godden
 
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...Rouven Weßling
 
2021.laravelconf.tw.slides2
2021.laravelconf.tw.slides22021.laravelconf.tw.slides2
2021.laravelconf.tw.slides2LiviaLiaoFontech
 
Learn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshopLearn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshopchartjes
 
Handling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMHandling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMMin-Yih Hsu
 
DARPA CGC and DEFCON CTF: Automatic Attack and Defense Technique
DARPA CGC and DEFCON CTF: Automatic Attack and Defense TechniqueDARPA CGC and DEFCON CTF: Automatic Attack and Defense Technique
DARPA CGC and DEFCON CTF: Automatic Attack and Defense TechniqueChong-Kuan Chen
 
Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsGanesh Samarthyam
 
Static Code Analysis and Cppcheck
Static Code Analysis and CppcheckStatic Code Analysis and Cppcheck
Static Code Analysis and CppcheckZachary Blair
 
Static Code Analysis and AutoLint
Static Code Analysis and AutoLintStatic Code Analysis and AutoLint
Static Code Analysis and AutoLintLeander Hasty
 
Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Peter Kofler
 
Speed geeking-lotusscript
Speed geeking-lotusscriptSpeed geeking-lotusscript
Speed geeking-lotusscriptBill Buchan
 
From code to pattern, part one
From code to pattern, part oneFrom code to pattern, part one
From code to pattern, part oneBingfeng Zhao
 

What's hot (20)

Les race conditions, nos très chères amies
Les race conditions, nos très chères amiesLes race conditions, nos très chères amies
Les race conditions, nos très chères amies
 
What is the Joomla Framework and why do we need it?
What is the Joomla Framework and why do we need it?What is the Joomla Framework and why do we need it?
What is the Joomla Framework and why do we need it?
 
The why and how of moving to php 7
The why and how of moving to php 7The why and how of moving to php 7
The why and how of moving to php 7
 
The why and how of moving to php 8
The why and how of moving to php 8The why and how of moving to php 8
The why and how of moving to php 8
 
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...
 
Erlang White Label
Erlang White LabelErlang White Label
Erlang White Label
 
2021.laravelconf.tw.slides2
2021.laravelconf.tw.slides22021.laravelconf.tw.slides2
2021.laravelconf.tw.slides2
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
Cgc2
Cgc2Cgc2
Cgc2
 
Learn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshopLearn To Test Like A Grumpy Programmer - 3 hour workshop
Learn To Test Like A Grumpy Programmer - 3 hour workshop
 
Handling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMHandling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVM
 
Eval4j @ JVMLS 2014
Eval4j @ JVMLS 2014Eval4j @ JVMLS 2014
Eval4j @ JVMLS 2014
 
DARPA CGC and DEFCON CTF: Automatic Attack and Defense Technique
DARPA CGC and DEFCON CTF: Automatic Attack and Defense TechniqueDARPA CGC and DEFCON CTF: Automatic Attack and Defense Technique
DARPA CGC and DEFCON CTF: Automatic Attack and Defense Technique
 
Cracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 ExamsCracking OCA and OCP Java 8 Exams
Cracking OCA and OCP Java 8 Exams
 
Static Code Analysis and Cppcheck
Static Code Analysis and CppcheckStatic Code Analysis and Cppcheck
Static Code Analysis and Cppcheck
 
Static Code Analysis and AutoLint
Static Code Analysis and AutoLintStatic Code Analysis and AutoLint
Static Code Analysis and AutoLint
 
Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)
 
Speed geeking-lotusscript
Speed geeking-lotusscriptSpeed geeking-lotusscript
Speed geeking-lotusscript
 
From code to pattern, part one
From code to pattern, part oneFrom code to pattern, part one
From code to pattern, part one
 
Doing the Impossible
Doing the ImpossibleDoing the Impossible
Doing the Impossible
 

Viewers also liked

Viewers also liked (20)

My Favorite Things
My Favorite ThingsMy Favorite Things
My Favorite Things
 
Video analysis - Paramore
Video analysis - ParamoreVideo analysis - Paramore
Video analysis - Paramore
 
Immigrants And Cities
Immigrants And CitiesImmigrants And Cities
Immigrants And Cities
 
Prezentacja O Na-chiny
Prezentacja O Na-chinyPrezentacja O Na-chiny
Prezentacja O Na-chiny
 
Flip Chart[1]
Flip Chart[1]Flip Chart[1]
Flip Chart[1]
 
Socialcultural Factors Presentation
Socialcultural Factors PresentationSocialcultural Factors Presentation
Socialcultural Factors Presentation
 
Hawaii Weather Article Report
Hawaii Weather Article ReportHawaii Weather Article Report
Hawaii Weather Article Report
 
Magazine Production
Magazine ProductionMagazine Production
Magazine Production
 
Gallery#3
Gallery#3Gallery#3
Gallery#3
 
Torre eiffel
Torre eiffelTorre eiffel
Torre eiffel
 
Giving credit to borrowed graphics
Giving credit to borrowed graphicsGiving credit to borrowed graphics
Giving credit to borrowed graphics
 
Academic Writing
Academic WritingAcademic Writing
Academic Writing
 
Conversatorio
ConversatorioConversatorio
Conversatorio
 
Writing J27
Writing J27Writing J27
Writing J27
 
Digital trends that matter for business
Digital trends that matter for businessDigital trends that matter for business
Digital trends that matter for business
 
Frontend devops-v1.0
Frontend devops-v1.0Frontend devops-v1.0
Frontend devops-v1.0
 
Intro to Interns
Intro to InternsIntro to Interns
Intro to Interns
 
Powerpoint News
Powerpoint NewsPowerpoint News
Powerpoint News
 
Jorge Delgado Work
Jorge Delgado  WorkJorge Delgado  Work
Jorge Delgado Work
 
Portugal Ii
Portugal IiPortugal Ii
Portugal Ii
 

Similar to Variety of automated tests

これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)goccy
 
Orange@php conf
Orange@php confOrange@php conf
Orange@php confHash Lin
 
Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧Orange Tsai
 
Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023Scott Keck-Warren
 
Behat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdfBehat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdfseleniumbootcamp
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4Wim Godden
 
Unit testing with Spock Framework
Unit testing with Spock FrameworkUnit testing with Spock Framework
Unit testing with Spock FrameworkEugene Dvorkin
 
Finding Needles in Haystacks
Finding Needles in HaystacksFinding Needles in Haystacks
Finding Needles in Haystackssnyff
 
Property based testing - Less is more
Property based testing - Less is moreProperty based testing - Less is more
Property based testing - Less is moreHo Tien VU
 
From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...Yury Bushmelev
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task QueueRichard Leland
 
20140406 loa days-tdd-with_puppet_tutorial
20140406 loa days-tdd-with_puppet_tutorial20140406 loa days-tdd-with_puppet_tutorial
20140406 loa days-tdd-with_puppet_tutorialgarrett honeycutt
 
ONOS System Test - ONS2016
ONOS System Test - ONS2016ONOS System Test - ONS2016
ONOS System Test - ONS2016Suibin Zhang
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Michelangelo van Dam
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshopDamien Seguy
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!Ortus Solutions, Corp
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Michelangelo van Dam
 
Workshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublinWorkshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublinMichelangelo van Dam
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Mark Niebergall
 
Next Generation DevOps in Drupal: DrupalCamp London 2014
Next Generation DevOps in Drupal: DrupalCamp London 2014Next Generation DevOps in Drupal: DrupalCamp London 2014
Next Generation DevOps in Drupal: DrupalCamp London 2014Barney Hanlon
 

Similar to Variety of automated tests (20)

これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 
Orange@php conf
Orange@php confOrange@php conf
Orange@php conf
 
Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧Security in PHP - 那些在滲透測試的小技巧
Security in PHP - 那些在滲透測試的小技巧
 
Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023Static Code Analysis PHP[tek] 2023
Static Code Analysis PHP[tek] 2023
 
Behat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdfBehat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdf
 
The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
 
Unit testing with Spock Framework
Unit testing with Spock FrameworkUnit testing with Spock Framework
Unit testing with Spock Framework
 
Finding Needles in Haystacks
Finding Needles in HaystacksFinding Needles in Haystacks
Finding Needles in Haystacks
 
Property based testing - Less is more
Property based testing - Less is moreProperty based testing - Less is more
Property based testing - Less is more
 
From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task Queue
 
20140406 loa days-tdd-with_puppet_tutorial
20140406 loa days-tdd-with_puppet_tutorial20140406 loa days-tdd-with_puppet_tutorial
20140406 loa days-tdd-with_puppet_tutorial
 
ONOS System Test - ONS2016
ONOS System Test - ONS2016ONOS System Test - ONS2016
ONOS System Test - ONS2016
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 
Preparing code for Php 7 workshop
Preparing code for Php 7 workshopPreparing code for Php 7 workshop
Preparing code for Php 7 workshop
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Workshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublinWorkshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects - phpdublin
 
Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022Leveling Up With Unit Testing - LonghornPHP 2022
Leveling Up With Unit Testing - LonghornPHP 2022
 
Next Generation DevOps in Drupal: DrupalCamp London 2014
Next Generation DevOps in Drupal: DrupalCamp London 2014Next Generation DevOps in Drupal: DrupalCamp London 2014
Next Generation DevOps in Drupal: DrupalCamp London 2014
 

More from Артём Курапов (9)

Scaling GraphQL Subscriptions
Scaling GraphQL SubscriptionsScaling GraphQL Subscriptions
Scaling GraphQL Subscriptions
 
Symfony
SymfonySymfony
Symfony
 
Bacbkone js
Bacbkone jsBacbkone js
Bacbkone js
 
Php storm intro
Php storm introPhp storm intro
Php storm intro
 
Android intro
Android introAndroid intro
Android intro
 
В облаке AWS
В облаке AWSВ облаке AWS
В облаке AWS
 
Devclub hääletamine
Devclub hääletamineDevclub hääletamine
Devclub hääletamine
 
Visualization of evolutionary cascades of messages using force-directed graphs
Visualization of evolutionary cascades of messages using force-directed graphsVisualization of evolutionary cascades of messages using force-directed graphs
Visualization of evolutionary cascades of messages using force-directed graphs
 
OAuthоризация и API социальных сетей
OAuthоризация и API социальных сетейOAuthоризация и API социальных сетей
OAuthоризация и API социальных сетей
 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Variety of automated tests

  • 1. Variety of automated tests Artjom Kurapov
  • 2. Kurapov.ee   @tot_ra   10  years  in  IT  /  PHP   lvl  65  elf/hunter  
  • 3.
  • 4. Developer  QA  engineer   Fear  of  sudden  death  
  • 5.
  • 7. Objectivity - state or quality of being true even outside of a subject’s individual biases, interpretations, feelings, and imaginings.
  • 8. Client – I dropped a phone Test that it works
  • 10. OVERVIEW   MarFn  Fowler  hHp://marFnfowler.com/arFcles/microservice-­‐tesFng/   WHITE  GRAY  BLACK   SUBJECTIVE   IMPORTANCE   GITHUB  LINKS   TEST  FAMILY  
  • 11. PHP testing tools & authors SebasFan  Bergmann   @s_bergmann   atoum/atoum   mlively/Phake   ribozz/PhpSpock   marco-­‐fiset/TesFfy.php   SimpleTest   inclusive-­‐design/AChecker   Ciaran  McNulty   @ciaranmcnulty   KonstanFn  Kudryashov   @everzet   Michael  Bodnarchuk   @davert  
  • 14. Basic scenario tests •  Create  a  feature  list   – Register  as  new  user   – Register  with  coupon   – Login   – Checkout   •  Timeouts  between  commands   •  Hard-­‐coded  data   1   CodecepFon/CodecepFon   giorgiosironi/phpunit-­‐selenium   minkphp/MinkSelenium2Driver  
  • 15. UI testing tools •  Browser  controllers  –  Selenium,  Sahi   •  Headless  browsers   – CasperJS,  PhantomJS,  GouHe   •  Custom  stuff  -­‐  WaFr,  TestComplete,  iMacros   1   CodecepFon/CodecepFon   giorgiosironi/phpunit-­‐selenium   minkphp/MinkSelenium2Driver  
  • 16. 1  
  • 17. Sum  of  complexity   • Not  informaJve  if  fails   • Environment  maintenance   • New  tech     – dragging,  canvas,  svg,     – touch,  mulFtouch,  3d-­‐touch   1   CodecepFon/CodecepFon   giorgiosironi/phpunit-­‐selenium   minkphp/MinkSelenium2Driver  
  • 18. Instability  &  non-­‐determinism   • Async  -­‐  ajax,  animaFons,  upload   • HTML-­‐dependent   • Hard-­‐coded  data  &  dependent  tests   • External  websites   • Drivers   1   CodecepFon/CodecepFon   giorgiosironi/phpunit-­‐selenium   minkphp/MinkSelenium2Driver  
  • 19. AbstracFng  QA  framework   •  Syntax  improvement   •  Page  objects  +  Workflows   •  API  for  data  reset  /  VM  per  process   •  RepeaFng  funcFons   –  Login,  Messages   –  Form  saving,  Layout  mode   2   CodecepFon/CodecepFon   giorgiosironi/phpunit-­‐selenium   minkphp/MinkSelenium2Driver  
  • 20. Behaviour  tests   • Human-­‐readable  specificaFon   • Needs  parsing   • Business  people-­‐oriented   Behat/Behat   3  
  • 21. 3  
  • 22. 3  
  • 23. 3  
  • 24. Screenshots  /  CSS  regression   Pixel-­‐by-­‐pixel  comparison   Similarity  in  %   imagick::compareImages()   4   Huddle/PhantomCSS  
  • 26. Environment  diagnosFcs   •  RAM  /  HDD  /  file  permissions   •  Packages,  extensions,  libraries   •  Services  /  docker  containers      1  
  • 29. IntegraFon  external  APIs   • Availability  -­‐  FTP  /  REST  API   – server  is  down   – no  file  /  API  404   • CompaFbility   – empty  file   – wrong  json/XML  schema      2   guzzle/guzzle   CodecepFon/CodecepFon  
  • 31. Frontend / UI Backend / DB API Single  Page  ApplicaFon  
  • 32. Own  internal  API   •  HTTP  GET  on  all  endpoints   No  “Stack  trace”,  “error”,  “excepFon”  in  response     •  POST/PUT  for  data  change   –   Mobile  app  scenarios   –   UDP  +  binary  data   –   Image  upload      3   guzzle/guzzle   CodecepFon/CodecepFon  
  • 33. Why  you  need  to  test  with  real  DB   •  DB  specifics  –  dates  /  autoincrements   •  Stored  procedures   •  TransacFons   •  Handling  large  data   •  ORM  mapping      3  
  • 34. Internal  API  +  separate  DB     •  DB  isolaFon  for  each  test   •  Slow  &  SQL  fixtures  harder  to  maintain   •  AlternaFves   –  transacFon  &  rollback   –  Virtual  machine   –  raw  db  file  copy      4  
  • 36. Security + fuzzing tests Bruteforce  own  API   •  InjecFons  -­‐  sql,  xss   •  Argument  types   – bool,  array,  string,  json   •  Binary/Images   – Different  types,  sizes   drodil/PHP-­‐Fuzz-­‐tester      5  
  • 38.    5      
  • 40.        5  
  • 41.        5  
  • 42. Performance tests - backend •  Response  Fme  <  1s   •  DB  queries  <  15   •  Memory  load  <  10MB   •  Is  the  app  geong  slower?      6   jokkedk/webgrind  
  • 43. Data integrity/sync tests •  Check  data  in  N  services   – files  in  Mysql,  mongo,  AWS   •  JSON  schema,  NULLs,  Dates   Example  –  translaFons  export-­‐import  in  UTF16  CSV      7  
  • 44. Application migration/upgrade tests •  If  you  run  delta  scripts  /  migraFons  (like  phinx)   •  MigraFon  script  =  unit  tests   •  Data  integrity  auer  run      8  
  • 45. Configuration matrix tests If  you  support  mulFple  environment  combinaFons  (CMS)   •  Browsers   •  PHP  versions   •  Servers   •  OS   Virtualize!  –  docker,  vagrant   4*4*4*4 = 256 variations, but it can get worse    9  
  • 47. Unit tests •  Limited  to  isolated  funcFon  or  class   •  Data  processing  confirmaFon   – math  /  logic  /  price  calculators   – regexp  /  parsers  /  validators   – random()  raFo   sing()      1  
  • 48. Unit tests of private methods “you  should  not  test  privates,  its  a  bad  pracFce”   •  Abstract  class   •  Public  efficiency  /  cycles   •  Debug   new  ReflectionClass(‘Man’)-­‐>getMethod(‘urinate’)    -­‐>setAccessible(true)   urinate()      1  
  • 49. Unit tests calling private methods “(In  phpspec)  you  cannot  mock  system  under  test.   This  is  a  bad  pracFce”     runkit::method_redefine   urinate()      1   visitBathRoom()  
  • 52. Unit tests calling other classes Test  doubles:   •  Dummy  –  argument  that’s  not  used  (during  test)   •  Stub  –  hard-­‐coded  value   •  Spy  –  did  methods  got  called?   •  Fake  –  dynamic  stubs   •  Mock  –  all-­‐in-­‐one   padraic/mockery phpspec/prophecy Codeception/AspectMock sebastianbergmann/phpunit-mock-objects    2  
  • 53. Mocks ExpectaJons  of  coupling  dynamics:   •  What  objects/funcFons  to  be  called     •  Order  &  Fming   •  Arguments   •  Emulates  returns   •  ExcepFons      2   padraic/mockery phpspec/prophecy Codeception/AspectMock sebastianbergmann/phpunit-mock-objects
  • 54. man   home   sleep() Mocks useBed() protect() warm() store()    2   padraic/mockery phpspec/prophecy Codeception/AspectMock sebastianbergmann/phpunit-mock-objects
  • 55. Mocks – does it call something?    2   man   hostel   sleep() useBed() padraic/mockery phpspec/prophecy Codeception/AspectMock sebastianbergmann/phpunit-mock-objects
  • 57. + prophecy    2   Mocks with magic syntax
  • 58.    2   Mocks chains
  • 59.    2   Mock magic chains
  • 60.    2   Mocks – backward thinking Code   •  Update()   •  Pdo  prepare()   •  Statement  execute()   •  Statement  rowCount()   Test   •  Statement  execute()   •  Statement  rowCount()   •  Pdo  prepare()   •  Update()  
  • 61. Contracts man   wife   tests   tests      3   sex()   getNewKid()  
  • 62. Side 1 has expectations    3   man   Perfect   wife   sex_anyTime()   sex_noCondom()   getNewKid_hasMyHair()   sex()   getNewKid()  
  • 63. Side 2 has different expectations abortKid() findNewDaddy()    3   Rich   daddy   wife   sex_forPleasure()   getNewKid_auer30()   sex()   getNewKid()  
  • 64. Contracts – a smarter interface •  Input  validaFon   •  Method  call  sequence   •  Internal  state  limitaFons   •  Output  expectaFons   empty  array,  false,  Null,  array,  stdClass,  Inherited   enFty,  id-­‐based  map,  paginaFon  object…      3  
  • 65. Contracts – mock matcher man   wife      3   Contract  
  • 66. Contract tests ParFes  have  obligaFons   •  PrecondiFons  –  before  running  method   •  PostcondiFons   •  Invariants  –  limitaFons  for  the  enFre  class   lisachenko/php-­‐deal   stuartherbert/ContractLib      3  
  • 69. In-­‐memory  filesystem  tests   • built-­‐in  streaming  funcFon  support   – file_put_contents,  fwrite   • permissions  &  viewer   • large  file  support   • result  structure  asserFon   • relaFve  paths  are  not  supported   – chdir(),  realpath()  too   mikey179/vfsStream      4  
  • 71. In-memory database tests FuncFon  call  expected,  not  enFre  stack.  Fast,  but  narrow     PHPUnit_Extensions_Database_TestCase  -­‐  too  complex   •  Data  sources:  XML,  CSV,  mysql  dump   •  DB  virtualizaFon:  PDO  +  SQLite   See  also:  H2  Database,  HyperSQL,  Apache  Derby   sebasFanbergmann/dbunit   liip/LiipFuncFonalTestBundle      5  
  • 73. Component testing Component  /  library  -­‐  coherent,  replaceable  uFlity  classes     For  example:   -­‐  Form  builder  (please  don’t)   -­‐  Validator   -­‐  Logger   -­‐  Tree  builder   -­‐  Image  resizer   -­‐  File  storage  abstracFon   -­‐  CSV/XML  generator/parser   man   wife   cat   sofa   sleepOn() clean() destroy()    6  
  • 75. Speed - order by types PHPUNIT.xml   •  Unit  tests   –  General  project  unit  tests  (validators,  DB  adapter)   –  Unit  tests  per  component  (models)   •  IntegraFon  tests   –  External   –  Internal  API   –  Internal  with  DB  isolaFon   –  Performance  +  Security   –  Data  integrity   •  UI  tests   –  Screenshoong   Time  
  • 76. Modularity    /controllers/arFcle.php   /models/arFcle.php   /tests/integraFon/arFcleControllerTest.php   /tests/unit/arFcleModelTest.php     /arFcle/controller/   /article/model/   /article/modelTests/   /article/controllerTests/   Divide  your  app  into  modules  -­‐  see  what  tests  you  lack  where  
  • 77. Annotations jump  between  funcFon  and  test   @see  ArFcleController::postCreate     @Fcket  T-­‐1000  +  JIRA  API   (PHPUnit  supports)     @group  producFon   @group  failed   phpunit  -­‐-­‐testsuite  unit    
  • 78. More than code coverage Code  coverage  =  you  tried  to  test   Delta  coverage  –  what  test  adds     MutaFons  help  to  find     •  tests  that  lack  enough  asserts   •  fragile  code   henrikbjorn/PhpSpecCodeCoverageExtension  
  • 80. What else to test? •  Frontend   •  Stress  /  Load   •  SQL  procedures   •  Accessibility  tests   •  GlobalizaFon  
  • 81. Track your mistakes •  Monitoring  tests  failures   •  Coverage  trend   •  Test  quality   Monitoring  code  health:   •  Complexity   •  Code  standard  compliance   Block8/PHPCI Halleck45/PhpMetrics squizlabs/PHP_CodeSniffer  
  • 82. Awareness   Clarity   Tests   Architecture