SlideShare une entreprise Scribd logo
1  sur  36
Automated Tests
What? How? When?
Damian Sromek
damian.sromek@gmail.com
2016-04
Preface
There are many types of automatic tests, testing tools, libraries and approaches.
Automatic tests can save you a lot of stress but can also became a kind of a nightmare.
This presentation is an overview of what's available and how to use and not to use
them to make them really useful.
Examples taken from PHP world. You might be surprised how many tools is available.
Agenda
What is a test?
The tools
How to start and progress
Challenges
About me
Damian Sromek
PHP Developer since ~2010
BlaBlaCar.com; Weemto.com; Xstream.net; X-Formation.com
Linked In Profile
Test? Why?
To make the user happy.
To make your boss happy.
To make your company happy.
To make you happy.
Test
Make sure software works - quality assurance
Make sure software does what it’s supposed to do
Make sure software stays working
Test - Types
Large: Acceptance, End to end
User can buy a book using web browser
Medium: Integration, Functional
Internal API call to shop service works fine when external payment system is mocked.
Small: Unit
Class computes the price correctly.
Test
Manual
Performed by human - usually a student clicking all day long.
Automated
Performed by computer - usually PHPUnit clicking all day long.
Manual + Automated
Human tester clicking to prepare a new testing scenario that will be automated next.
Manual Testing
Clicking around (“random”, test plan)
“var_dump”
Debugging using debugger
Automated Tests
Computer is much faster at testing than human
Computer tool checks the software. Eg. clicks around
Deliver fast and with less worries - especially when working with many people
Protect against regression
Allows easier testing of edge and hard to reproduce cases
PHP tools
http://www.phptherightway.com/#testing
Automated Tests = Happy
Avoiding for slow, boring “monkey” testing
Avoiding testing again and again, … and again
You can debug easier
You know when you break things
You know when other people break things - they fix it
TDD, BDD, DDD
TDD - Test Driven Development
Know your software/class requirements before implementing it.
Behavior Driven Development
Know your business by writing down user’s behaviour
DDD - Domain Driven Design
Know your business first by modeling the domain and events
Development <-> Design
Automated E2E/Acceptance Tests
Selenium, Mink
Behat
Codeception
Storyplayer
PHPUnit
Automated Integration Tests
Test if multiple classes work together
Test if “classes” work properly with external WebService, Database
PHPUnit
Codeception
Behat (!) - contexts
Automated Unit Tests
PHPUnit
PHPSpec (BDD)
Codeception
CT, CI, CD
Continouos Testing
Continuous Integration
Continuous Delivery
Automation Platforms
Jenkins
Bamboo
Travis-CI
TeamCity
How? When?
Know your project, team, goals, definition of done
WordPress website vs banking system
Define risks and make a simple test plan
Text has wrong size vs user unable to pay
Start with the simplest solution and evolve
Other (Un)expected Benefits
Better understanding of “the purpose” of the software
Safer refactoring
Better code design and quality
Documentation of features and a design
Faster development of a better software!
Is it easy?
“It depends”
Need to learn a new things - tools, change the way of thinking.
Was learning OOP easy?
Writing Integration and Unit tests can be really hard if you have poor code design
Writing a good test requires you to “become a tester”
Learn
Books
Growing Object-Oriented Software, Guided by Tests
Testowanie i jakość oprogramowania. Metody, narzędzia, techniki
YouTube, conferences
Open source projects
Symfony: PHPUnit
Sylius: Behat, PHPSpec
Web
Wikipedia
Testing on toilet
Uncle Bob
Excuses
I create a code that works
It works on my computer
I don’t know how to write tests
I don’t like writing tests
I have no time for writing tests
It’s not possible to test this
It’s quite hard to measure the benefits
Good Start - Bugs!
1. Get a bug report
2. Reproduce it by writing an automatic test
3. Fix it!
Good Start - High Level
If you’re responsible for the whole project
Basic Acceptance Tests
then basic Integration Tests
then basic Unit Tests
But What Tool(s)?
A tool you or other devs are familiar with
A tool that’s quite popular - big comunity
A tool that fits your needs
As few tools you need
A tool with good support in IDE, automation platforms etc.
Usually PHPUnit would be a good start
Vagrant, Docker
“Great software development is not about the tools you use but about how you use
On the way
Use Continuous Testing (eg. Jenkins)
Keep tests close to the source code
Keep the tests quality at the best possible level
Have as much tests as you need - not more
Keep it simple
How much tests?
Acceptance < Integration < Unit
Keep test execution time as low as possible
Master Level
Test Driven Development / Design
Desing / Test -> Implement -> Refactor
IDE for running tests with debugger
Every feature and bug fix with an automatic test
You shall not merge on failing tests
Test groups, desciptive names and fail messages
The same test suites for many environments
Continuous Improvement
Try the simplest solution for your needs
Learn
Improve
Good Automated Test
Shows what the software does
Hides how the software works
“I should not be able to tell what’s the implementation by reading the test” - Me
Protects from bugs ;)
Should let you replace feature implementation
Should speed up your daily work
Fails with descriptive and easy to understand message
Is independent and repeatable
Challenges
Having a lot of poor quality code
Execution takes too long
Try to move to Unit tests. Acceptance tests for the simplest scenarios;
Database in RAMDisk
Mock-hell
Try not to overuse mocks. Some classes are made to integrate things.
Too many tests
Check if the tests are really usefull. If not then remove some.
Do they really check something useful?
Randomly failing tests
Try not to make tests depend on real time/date. Eg. mock the clock.
Quality Metrics
Number of tests and assertions
Execution time
Code coverage
Number of bugs found during development
Number of bugs protected against - regression
Speed of developing new, WORKING features
Certainty of releasing new version of software
Is it worth it?
YES!
Automation for the win!
Automated tests for the win!
Testing Legacy Projects
- Test only at a high level if you know your internals needs to be replaced/improved
Testing Large and Complex Systems
Online Video Platform
Web, Backend, Queue, Distributed
FTP upload; Wait for asynchronous actions; Check GUI;
Set Top Box app
Selenium; WebSockets
Behat scenarios in Jenkins task config
Exotic Tests
Mutation testing
Monitor performance (eg. number of SQL querries), profile
Database Migrations
Database (Doctrine) mapping
Questions?
Email: damian.sromek@gmail.com
Twitter: damiansromek
Blog: damiansromek.pl
Github: paq85
Thank you!

Contenu connexe

Tendances

Auditing Drupal Sites
Auditing Drupal SitesAuditing Drupal Sites
Auditing Drupal Sites
Exove
 
Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best Practices
Tomaš Maconko
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven Testing
Maveryx
 
Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015
Joe Ferguson
 
Advanced unit testing – real life examples and mistakes
Advanced unit testing – real life examples and mistakesAdvanced unit testing – real life examples and mistakes
Advanced unit testing – real life examples and mistakes
Milan Vukoje
 

Tendances (20)

Unit & integration testing
Unit & integration testingUnit & integration testing
Unit & integration testing
 
Drupal 7 ci and testing
Drupal 7 ci and testingDrupal 7 ci and testing
Drupal 7 ci and testing
 
DotNet unit testing training
DotNet unit testing trainingDotNet unit testing training
DotNet unit testing training
 
Five Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal SiteFive Easy Ways to QA Your Drupal Site
Five Easy Ways to QA Your Drupal Site
 
Auditing Drupal Sites
Auditing Drupal SitesAuditing Drupal Sites
Auditing Drupal Sites
 
How to Build and Maintain Quality Drupal Sites with Automated Testing
How to Build and Maintain Quality Drupal Sites with Automated TestingHow to Build and Maintain Quality Drupal Sites with Automated Testing
How to Build and Maintain Quality Drupal Sites with Automated Testing
 
PHPUnit with CakePHP and Yii
PHPUnit with CakePHP and YiiPHPUnit with CakePHP and Yii
PHPUnit with CakePHP and Yii
 
Selenium Frameworks
Selenium FrameworksSelenium Frameworks
Selenium Frameworks
 
Introducing Keyword-driven Test Automation
Introducing Keyword-driven Test AutomationIntroducing Keyword-driven Test Automation
Introducing Keyword-driven Test Automation
 
Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best Practices
 
CI / CD w/ Codeception
CI / CD w/ CodeceptionCI / CD w/ Codeception
CI / CD w/ Codeception
 
Impact Analysis - LoopConf
Impact Analysis - LoopConfImpact Analysis - LoopConf
Impact Analysis - LoopConf
 
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven development
 
Real Life Unit Testing
Real Life Unit TestingReal Life Unit Testing
Real Life Unit Testing
 
The Testing Planet - July 2010
The Testing Planet - July 2010The Testing Planet - July 2010
The Testing Planet - July 2010
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven Testing
 
Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015
 
Creating testing tools to support development
Creating testing tools to support developmentCreating testing tools to support development
Creating testing tools to support development
 
Advanced unit testing – real life examples and mistakes
Advanced unit testing – real life examples and mistakesAdvanced unit testing – real life examples and mistakes
Advanced unit testing – real life examples and mistakes
 

Similaire à Automated tests

The Testing Planet Issue 2
The Testing Planet Issue 2The Testing Planet Issue 2
The Testing Planet Issue 2
Rosie Sherry
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
Vijayan Reddy
 
I Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application TestingI Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application Testing
Peter Presnell
 
Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009
Grig Gheorghiu
 

Similaire à Automated tests (20)

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 
How to run an Enterprise PHP Shop
How to run an Enterprise PHP ShopHow to run an Enterprise PHP Shop
How to run an Enterprise PHP Shop
 
Tdd
TddTdd
Tdd
 
The Testing Planet Issue 2
The Testing Planet Issue 2The Testing Planet Issue 2
The Testing Planet Issue 2
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
AutomationTesting
AutomationTestingAutomationTesting
AutomationTesting
 
Automation testing: how tools are important?
Automation testing: how tools are important?Automation testing: how tools are important?
Automation testing: how tools are important?
 
I Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application TestingI Smell A RAT- Rapid Application Testing
I Smell A RAT- Rapid Application Testing
 
Developers Border Line: Unit Testing
Developers Border Line: Unit TestingDevelopers Border Line: Unit Testing
Developers Border Line: Unit Testing
 
Myths and reality about software testing
Myths and reality about software testingMyths and reality about software testing
Myths and reality about software testing
 
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austinDev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
Dev ops ci-ap-is-oh-my_security-gone-agile_ut-austin
 
Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Enterprise Development on a Shoestring Budget
Enterprise Development on a Shoestring BudgetEnterprise Development on a Shoestring Budget
Enterprise Development on a Shoestring Budget
 
How to Deliver the Right Software (Specification by example)
How to Deliver the Right Software (Specification by example)How to Deliver the Right Software (Specification by example)
How to Deliver the Right Software (Specification by example)
 

Dernier

Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Dernier (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 

Automated tests

  • 1. Automated Tests What? How? When? Damian Sromek damian.sromek@gmail.com 2016-04
  • 2. Preface There are many types of automatic tests, testing tools, libraries and approaches. Automatic tests can save you a lot of stress but can also became a kind of a nightmare. This presentation is an overview of what's available and how to use and not to use them to make them really useful. Examples taken from PHP world. You might be surprised how many tools is available.
  • 3. Agenda What is a test? The tools How to start and progress Challenges
  • 4. About me Damian Sromek PHP Developer since ~2010 BlaBlaCar.com; Weemto.com; Xstream.net; X-Formation.com Linked In Profile
  • 5. Test? Why? To make the user happy. To make your boss happy. To make your company happy. To make you happy.
  • 6. Test Make sure software works - quality assurance Make sure software does what it’s supposed to do Make sure software stays working
  • 7. Test - Types Large: Acceptance, End to end User can buy a book using web browser Medium: Integration, Functional Internal API call to shop service works fine when external payment system is mocked. Small: Unit Class computes the price correctly.
  • 8. Test Manual Performed by human - usually a student clicking all day long. Automated Performed by computer - usually PHPUnit clicking all day long. Manual + Automated Human tester clicking to prepare a new testing scenario that will be automated next.
  • 9. Manual Testing Clicking around (“random”, test plan) “var_dump” Debugging using debugger
  • 10. Automated Tests Computer is much faster at testing than human Computer tool checks the software. Eg. clicks around Deliver fast and with less worries - especially when working with many people Protect against regression Allows easier testing of edge and hard to reproduce cases PHP tools http://www.phptherightway.com/#testing
  • 11. Automated Tests = Happy Avoiding for slow, boring “monkey” testing Avoiding testing again and again, … and again You can debug easier You know when you break things You know when other people break things - they fix it
  • 12. TDD, BDD, DDD TDD - Test Driven Development Know your software/class requirements before implementing it. Behavior Driven Development Know your business by writing down user’s behaviour DDD - Domain Driven Design Know your business first by modeling the domain and events Development <-> Design
  • 13. Automated E2E/Acceptance Tests Selenium, Mink Behat Codeception Storyplayer PHPUnit
  • 14. Automated Integration Tests Test if multiple classes work together Test if “classes” work properly with external WebService, Database PHPUnit Codeception Behat (!) - contexts
  • 16. CT, CI, CD Continouos Testing Continuous Integration Continuous Delivery
  • 18. How? When? Know your project, team, goals, definition of done WordPress website vs banking system Define risks and make a simple test plan Text has wrong size vs user unable to pay Start with the simplest solution and evolve
  • 19. Other (Un)expected Benefits Better understanding of “the purpose” of the software Safer refactoring Better code design and quality Documentation of features and a design Faster development of a better software!
  • 20. Is it easy? “It depends” Need to learn a new things - tools, change the way of thinking. Was learning OOP easy? Writing Integration and Unit tests can be really hard if you have poor code design Writing a good test requires you to “become a tester”
  • 21. Learn Books Growing Object-Oriented Software, Guided by Tests Testowanie i jakość oprogramowania. Metody, narzędzia, techniki YouTube, conferences Open source projects Symfony: PHPUnit Sylius: Behat, PHPSpec Web Wikipedia Testing on toilet Uncle Bob
  • 22. Excuses I create a code that works It works on my computer I don’t know how to write tests I don’t like writing tests I have no time for writing tests It’s not possible to test this It’s quite hard to measure the benefits
  • 23. Good Start - Bugs! 1. Get a bug report 2. Reproduce it by writing an automatic test 3. Fix it!
  • 24. Good Start - High Level If you’re responsible for the whole project Basic Acceptance Tests then basic Integration Tests then basic Unit Tests
  • 25. But What Tool(s)? A tool you or other devs are familiar with A tool that’s quite popular - big comunity A tool that fits your needs As few tools you need A tool with good support in IDE, automation platforms etc. Usually PHPUnit would be a good start Vagrant, Docker “Great software development is not about the tools you use but about how you use
  • 26. On the way Use Continuous Testing (eg. Jenkins) Keep tests close to the source code Keep the tests quality at the best possible level Have as much tests as you need - not more Keep it simple How much tests? Acceptance < Integration < Unit Keep test execution time as low as possible
  • 27. Master Level Test Driven Development / Design Desing / Test -> Implement -> Refactor IDE for running tests with debugger Every feature and bug fix with an automatic test You shall not merge on failing tests Test groups, desciptive names and fail messages The same test suites for many environments
  • 28. Continuous Improvement Try the simplest solution for your needs Learn Improve
  • 29. Good Automated Test Shows what the software does Hides how the software works “I should not be able to tell what’s the implementation by reading the test” - Me Protects from bugs ;) Should let you replace feature implementation Should speed up your daily work Fails with descriptive and easy to understand message Is independent and repeatable
  • 30. Challenges Having a lot of poor quality code Execution takes too long Try to move to Unit tests. Acceptance tests for the simplest scenarios; Database in RAMDisk Mock-hell Try not to overuse mocks. Some classes are made to integrate things. Too many tests Check if the tests are really usefull. If not then remove some. Do they really check something useful? Randomly failing tests Try not to make tests depend on real time/date. Eg. mock the clock.
  • 31. Quality Metrics Number of tests and assertions Execution time Code coverage Number of bugs found during development Number of bugs protected against - regression Speed of developing new, WORKING features Certainty of releasing new version of software
  • 32. Is it worth it? YES! Automation for the win! Automated tests for the win!
  • 33. Testing Legacy Projects - Test only at a high level if you know your internals needs to be replaced/improved
  • 34. Testing Large and Complex Systems Online Video Platform Web, Backend, Queue, Distributed FTP upload; Wait for asynchronous actions; Check GUI; Set Top Box app Selenium; WebSockets Behat scenarios in Jenkins task config
  • 35. Exotic Tests Mutation testing Monitor performance (eg. number of SQL querries), profile Database Migrations Database (Doctrine) mapping