SlideShare a Scribd company logo
Codeception 
Introduction to PHP testing 
Thomas Dutrion / @tdutrion - September 2014
About me 
● Founder and developer/architect at Engineor 
● Working with PHP since 2003 
● Trying to work properly... 
@tdutrion / @engineor / thomas@engineor.com
PHP3: simple web pages 
PHP4: object? are you kidding? 
PHP5: mature language, with namespaces, real objects and so on… 
What is missing to compete with other languages? 
TESTABILITY 
Codeception 
PHP best practice: industrialisation
● Unit testing 
● Integration testing 
● Functional testing 
● Acceptance testing 
● Mutation testing 
● Monkey testing 
● ... 
Codeception 
What can we test? 
And you, how are you testing?
● Small unit of code 
● SOLID principle (single Responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion) 
● Requires complete isolation 
● Long to write, requires continuous updates, expensive 
=> very good for critical parts of the application! 
Codeception 
Unit testing
● Test modules as groups 
● Simulate input 
● Less work than Unit testing (smaller number of tests) 
Codeception 
Integration testing
● Test final application appearance 
● Reproduce complete application execution 
● Client point of view 
● Less code, final result only, help on legacy projects 
=> Can be used to prove the completion of the project 
Codeception 
Acceptance testing
Codeception 
One tool: Codeception
General introduction 
Codeception 
History: 
● Started in 2011 
● Stable release in January 2012 
● Version 2.0.5 in August 2014! 
● Currently 2725 commits 
● 175 contributors... 
Problem solved: 
● Bridge between all testing types 
● No other languages required 
● Extensible 
● Covers major frameworks
PHP 5.4 minimum!!!! (you can do that, right!) 
Codeception
You already know it! 
Based on recommended and proven tools 
● PHPUnit 
● Symfony browserkit 
● Selenium / PhantomJS (optional) 
● … 
Test suite written in PHP => no need to learn another language. 
Codeception
Follow the quickstart! 
1. Install codeception (prefer using composer, globally or in dev only) 
2. Bootstrap (directories and files structure, basic configuration) 
3. Generate acceptance testing 
4. Write tests 
5. And run! 
Codeception 
Acceptance testing 101
$ php vendor/bin/codecept run 
Codeception PHP Testing Framework v2.0.5 
Powered by PHPUnit 4.2.5 by Sebastian Bergmann. 
Acceptance Tests (1) ------------------------------------------------------------------------------------------------------------ 
Trying to ensure that frontpage works (WelcomeCept) Ok 
--------------------------------------------------------------------------------------------------------------------------------- 
Functional Tests (0) --------------------------------------------------------------------- 
Unit Tests (0) --------------------------------------------------------------------------- 
Time: 382 ms, Memory: 8.50Mb 
OK (1 test, 1 assertion) 
Codeception 
Basic example results (pass)
Acceptance Tests (1) ------------------------------------------------------------------------------------------------------------ 
Trying to ensure that frontpage works (WelcomeCept) Fail 
There was 1 failure: 
1) Failed to ensure that frontpage works in WelcomeCept (/Users/thomas/NetBeansProjects/Codeception01/tests/acceptance/WelcomeCept. 
php) 
Couldn't see "Not ok": 
Failed asserting that / 
→ Your HTML code here 
[Content too long to display. See complete response in '_output' directory] 
--> contains "not ok". 
Scenario Steps: 
2. I see "Not ok" 
1. I am on page "/" 
FAILURES! 
Tests: 1, Assertions: 1, Failures: 1. 
Codeception 
Basic example results (fail)
● Since 2005, AJAX is everywhere (XmlHttpRequest) 
● New architecture: MVVM javascript in front, PHP/node… in back 
Testing problem: PHPBrowser / Curl can not read javascript modifications. 
=> Codeception can work with Selenium! 
Codeception 
What about sexy frontends?
Demonstration: Firefox run
● No Firefox and or java on your servers => no Selenium on CI 
● CI usually run only simple bash scripts 
● Need to run the test in command line, emulating an headless browser 
=> Codeception PhantomJS driver 
Codeception 
Headless testing for Continuous Integration
Codeception 
Demonstration: headless run
Workflow improvement 
● Use Docker containers or Vagrant virtual boxes to add development, testing 
Codeception 
and production servers configuration to your VCS repository 
● Add CI server triggered on commits, with email results
Questions? 
Special thanks to / reading recommendation: 
● Jeremy Coates (@phpcodemonkey) for Testing with codeception 
● PHPNW (@phpnw), great PHP group that made me discover Codeception 
● All of you for your patience and supporting my French accent! 
● Glasgow PHP (@glasgowphp) to let me talk here 
Please rate and comment this talk on SlideShare: http://goo.gl/uJIh7G 
Codeception: introduction to PHP testing, by Thomas Dutrion from Engineor for Glasgow PHP, September 2014

More Related Content

PDF
Codeception introduction and use in Yii
PDF
Codeception
PDF
Testing with Codeception
PPTX
Test automation with php codeception
PDF
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
PDF
Acceptance & Functional Testing with Codeception - Devspace 2015
PDF
Codeception presentation
PDF
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Codeception introduction and use in Yii
Codeception
Testing with Codeception
Test automation with php codeception
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - Devspace 2015
Codeception presentation
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)

What's hot (20)

PPTX
Codeception
PDF
Acceptance testing in php with Codeception - Techmeetup Edinburgh
PDF
PHP Unit Testing in Yii
PPTX
CI / CD w/ Codeception
PDF
Testing PHP with Codeception
PDF
From Good to Great: Functional and Acceptance Testing in WordPress.
PDF
Testing with Codeception (Webelement #30)
PDF
Codeception: introduction to php testing (v2 - Aberdeen php)
PPTX
Automation using Javascript
PPTX
Automated UI testing done right (DDDSydney)
DOCX
Automation Frame works Instruction Sheet
PDF
Front-End Testing: Demystified
PDF
Selenium Basics Tutorial
PDF
Testing Web Applications
PPTX
Testing with laravel
ODP
Integration Testing in Python
PDF
Selenium Automation Testing Interview Questions And Answers
PDF
Top trending selenium interview questions
PDF
Selenium - Introduction
PDF
Unit testing - A&BP CC
Codeception
Acceptance testing in php with Codeception - Techmeetup Edinburgh
PHP Unit Testing in Yii
CI / CD w/ Codeception
Testing PHP with Codeception
From Good to Great: Functional and Acceptance Testing in WordPress.
Testing with Codeception (Webelement #30)
Codeception: introduction to php testing (v2 - Aberdeen php)
Automation using Javascript
Automated UI testing done right (DDDSydney)
Automation Frame works Instruction Sheet
Front-End Testing: Demystified
Selenium Basics Tutorial
Testing Web Applications
Testing with laravel
Integration Testing in Python
Selenium Automation Testing Interview Questions And Answers
Top trending selenium interview questions
Selenium - Introduction
Unit testing - A&BP CC
Ad

Similar to Codeception: introduction to php testing (20)

PDF
Mykhailo Bodnarchuk "The history of the Codeception project"
PPTX
Code ceptioninstallation
PDF
Testing mit Codeception: Full-stack testing PHP framework
PDF
Variety of automated tests
PDF
Codeception Testing Framework -- English #phpkansai
PDF
Put an end to regression with codeception testing
PDF
Workshop quality assurance for php projects - phpdublin
KEY
Workshop quality assurance for php projects tek12
PPTX
Getting started-php unit
KEY
Developer testing 201: When to Mock and When to Integrate
PPTX
Codeception @ New Business Dept Adira Finance
PDF
Code Coverage for Total Security in Application Migrations
PDF
PHPunit and you
PDF
Quality Assurance for PHP projects - ZendCon 2012
KEY
Prepare for PHP Test Fest 2009
ZIP
Test
PDF
Test your code like a pro - PHPUnit in practice
PDF
TAKING PHP SERIOUSLY - Keith Adams
PPTX
Php test fest
PPTX
PHPUnit: from zero to hero
Mykhailo Bodnarchuk "The history of the Codeception project"
Code ceptioninstallation
Testing mit Codeception: Full-stack testing PHP framework
Variety of automated tests
Codeception Testing Framework -- English #phpkansai
Put an end to regression with codeception testing
Workshop quality assurance for php projects - phpdublin
Workshop quality assurance for php projects tek12
Getting started-php unit
Developer testing 201: When to Mock and When to Integrate
Codeception @ New Business Dept Adira Finance
Code Coverage for Total Security in Application Migrations
PHPunit and you
Quality Assurance for PHP projects - ZendCon 2012
Prepare for PHP Test Fest 2009
Test
Test your code like a pro - PHPUnit in practice
TAKING PHP SERIOUSLY - Keith Adams
Php test fest
PHPUnit: from zero to hero
Ad

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Cloud computing and distributed systems.
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
KodekX | Application Modernization Development
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPT
Teaching material agriculture food technology
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation theory and applications.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Cloud computing and distributed systems.
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Building Integrated photovoltaic BIPV_UPV.pdf
Understanding_Digital_Forensics_Presentation.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Mobile App Security Testing_ A Comprehensive Guide.pdf
KodekX | Application Modernization Development
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Teaching material agriculture food technology
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Reach Out and Touch Someone: Haptics and Empathic Computing
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
The AUB Centre for AI in Media Proposal.docx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation theory and applications.pdf

Codeception: introduction to php testing

  • 1. Codeception Introduction to PHP testing Thomas Dutrion / @tdutrion - September 2014
  • 2. About me ● Founder and developer/architect at Engineor ● Working with PHP since 2003 ● Trying to work properly... @tdutrion / @engineor / thomas@engineor.com
  • 3. PHP3: simple web pages PHP4: object? are you kidding? PHP5: mature language, with namespaces, real objects and so on… What is missing to compete with other languages? TESTABILITY Codeception PHP best practice: industrialisation
  • 4. ● Unit testing ● Integration testing ● Functional testing ● Acceptance testing ● Mutation testing ● Monkey testing ● ... Codeception What can we test? And you, how are you testing?
  • 5. ● Small unit of code ● SOLID principle (single Responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion) ● Requires complete isolation ● Long to write, requires continuous updates, expensive => very good for critical parts of the application! Codeception Unit testing
  • 6. ● Test modules as groups ● Simulate input ● Less work than Unit testing (smaller number of tests) Codeception Integration testing
  • 7. ● Test final application appearance ● Reproduce complete application execution ● Client point of view ● Less code, final result only, help on legacy projects => Can be used to prove the completion of the project Codeception Acceptance testing
  • 8. Codeception One tool: Codeception
  • 9. General introduction Codeception History: ● Started in 2011 ● Stable release in January 2012 ● Version 2.0.5 in August 2014! ● Currently 2725 commits ● 175 contributors... Problem solved: ● Bridge between all testing types ● No other languages required ● Extensible ● Covers major frameworks
  • 10. PHP 5.4 minimum!!!! (you can do that, right!) Codeception
  • 11. You already know it! Based on recommended and proven tools ● PHPUnit ● Symfony browserkit ● Selenium / PhantomJS (optional) ● … Test suite written in PHP => no need to learn another language. Codeception
  • 12. Follow the quickstart! 1. Install codeception (prefer using composer, globally or in dev only) 2. Bootstrap (directories and files structure, basic configuration) 3. Generate acceptance testing 4. Write tests 5. And run! Codeception Acceptance testing 101
  • 13. $ php vendor/bin/codecept run Codeception PHP Testing Framework v2.0.5 Powered by PHPUnit 4.2.5 by Sebastian Bergmann. Acceptance Tests (1) ------------------------------------------------------------------------------------------------------------ Trying to ensure that frontpage works (WelcomeCept) Ok --------------------------------------------------------------------------------------------------------------------------------- Functional Tests (0) --------------------------------------------------------------------- Unit Tests (0) --------------------------------------------------------------------------- Time: 382 ms, Memory: 8.50Mb OK (1 test, 1 assertion) Codeception Basic example results (pass)
  • 14. Acceptance Tests (1) ------------------------------------------------------------------------------------------------------------ Trying to ensure that frontpage works (WelcomeCept) Fail There was 1 failure: 1) Failed to ensure that frontpage works in WelcomeCept (/Users/thomas/NetBeansProjects/Codeception01/tests/acceptance/WelcomeCept. php) Couldn't see "Not ok": Failed asserting that / → Your HTML code here [Content too long to display. See complete response in '_output' directory] --> contains "not ok". Scenario Steps: 2. I see "Not ok" 1. I am on page "/" FAILURES! Tests: 1, Assertions: 1, Failures: 1. Codeception Basic example results (fail)
  • 15. ● Since 2005, AJAX is everywhere (XmlHttpRequest) ● New architecture: MVVM javascript in front, PHP/node… in back Testing problem: PHPBrowser / Curl can not read javascript modifications. => Codeception can work with Selenium! Codeception What about sexy frontends?
  • 17. ● No Firefox and or java on your servers => no Selenium on CI ● CI usually run only simple bash scripts ● Need to run the test in command line, emulating an headless browser => Codeception PhantomJS driver Codeception Headless testing for Continuous Integration
  • 19. Workflow improvement ● Use Docker containers or Vagrant virtual boxes to add development, testing Codeception and production servers configuration to your VCS repository ● Add CI server triggered on commits, with email results
  • 20. Questions? Special thanks to / reading recommendation: ● Jeremy Coates (@phpcodemonkey) for Testing with codeception ● PHPNW (@phpnw), great PHP group that made me discover Codeception ● All of you for your patience and supporting my French accent! ● Glasgow PHP (@glasgowphp) to let me talk here Please rate and comment this talk on SlideShare: http://goo.gl/uJIh7G Codeception: introduction to PHP testing, by Thomas Dutrion from Engineor for Glasgow PHP, September 2014