SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

Acceptance testing in php with Codeception - Techmeetup Edinburgh
Acceptance testing in php with Codeception - Techmeetup EdinburghAcceptance testing in php with Codeception - Techmeetup Edinburgh
Acceptance testing in php with Codeception - Techmeetup EdinburghEngineor
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in YiiIlPeach
 
CI / CD w/ Codeception
CI / CD w/ CodeceptionCI / CD w/ Codeception
CI / CD w/ CodeceptionTudor Barbu
 
Testing PHP with Codeception
Testing PHP with CodeceptionTesting PHP with Codeception
Testing PHP with CodeceptionJohn Paul Ada
 
From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.David Aguilera
 
Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)Adam Štipák
 
Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)Engineor
 
Automation using Javascript
Automation using JavascriptAutomation using Javascript
Automation using Javascriptkhanhdang1214
 
Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)Mehdi Khalili
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction SheetvodQA
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: DemystifiedSeth McLaughlin
 
Selenium Basics Tutorial
Selenium Basics TutorialSelenium Basics Tutorial
Selenium Basics TutorialClever Moe
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web ApplicationsSeth McLaughlin
 
Testing with laravel
Testing with laravelTesting with laravel
Testing with laravelDerek Binkley
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersAjit Jadhav
 
Top trending selenium interview questions
Top trending selenium interview questionsTop trending selenium interview questions
Top trending selenium interview questionsRock Interview
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - IntroductionAmr E. Mohamed
 

La actualidad más candente (20)

Codeception
CodeceptionCodeception
Codeception
 
Acceptance testing in php with Codeception - Techmeetup Edinburgh
Acceptance testing in php with Codeception - Techmeetup EdinburghAcceptance testing in php with Codeception - Techmeetup Edinburgh
Acceptance testing in php with Codeception - Techmeetup Edinburgh
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in Yii
 
CI / CD w/ Codeception
CI / CD w/ CodeceptionCI / CD w/ Codeception
CI / CD w/ Codeception
 
Testing PHP with Codeception
Testing PHP with CodeceptionTesting PHP with Codeception
Testing PHP with Codeception
 
From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.From Good to Great: Functional and Acceptance Testing in WordPress.
From Good to Great: Functional and Acceptance Testing in WordPress.
 
Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)
 
Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)Codeception: introduction to php testing (v2 - Aberdeen php)
Codeception: introduction to php testing (v2 - Aberdeen php)
 
Automation using Javascript
Automation using JavascriptAutomation using Javascript
Automation using Javascript
 
Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)Automated UI testing done right (DDDSydney)
Automated UI testing done right (DDDSydney)
 
Automation Frame works Instruction Sheet
Automation Frame works Instruction SheetAutomation Frame works Instruction Sheet
Automation Frame works Instruction Sheet
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: Demystified
 
Selenium Basics Tutorial
Selenium Basics TutorialSelenium Basics Tutorial
Selenium Basics Tutorial
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web Applications
 
Testing with laravel
Testing with laravelTesting with laravel
Testing with laravel
 
Integration Testing in Python
Integration Testing in PythonIntegration Testing in Python
Integration Testing in Python
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
 
Top trending selenium interview questions
Top trending selenium interview questionsTop trending selenium interview questions
Top trending selenium interview questions
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - Introduction
 
Unit testing - A&BP CC
Unit testing - A&BP CCUnit testing - A&BP CC
Unit testing - A&BP CC
 

Similar a Codeception: introduction to php testing

Joomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingJoomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingShyam Sunder Verma
 
Continuous Integration In Php
Continuous Integration In PhpContinuous Integration In Php
Continuous Integration In PhpWilco Jansen
 
Codeception @ New Business Dept Adira Finance
Codeception @ New Business Dept Adira FinanceCodeception @ New Business Dept Adira Finance
Codeception @ New Business Dept Adira FinanceFachrul Choliluddin
 
[ENGLISH] TDC 2015 - PHP Trail - Tests and PHP Continuous Integration Enviro...
[ENGLISH] TDC 2015 - PHP  Trail - Tests and PHP Continuous Integration Enviro...[ENGLISH] TDC 2015 - PHP  Trail - Tests and PHP Continuous Integration Enviro...
[ENGLISH] TDC 2015 - PHP Trail - Tests and PHP Continuous Integration Enviro...Bruno Tanoue
 
Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Sam Becker
 
Pragmatic Introduction to PHP Unit Testing (2015)
Pragmatic Introduction to PHP Unit Testing (2015)Pragmatic Introduction to PHP Unit Testing (2015)
Pragmatic Introduction to PHP Unit Testing (2015)Peter Kofler
 
Behaviour testing for single-page applications and API’s
Behaviour testing for single-page applications and API’sBehaviour testing for single-page applications and API’s
Behaviour testing for single-page applications and API’sAndrew Kirkpatrick
 
Behaviour Testing and Continuous Integration with Drupal
Behaviour Testing and Continuous Integration with DrupalBehaviour Testing and Continuous Integration with Drupal
Behaviour Testing and Continuous Integration with Drupalsmithmilner
 
Continuous Integration at Mollie
Continuous Integration at MollieContinuous Integration at Mollie
Continuous Integration at Molliewillemstuursma
 
TDD for joomla extensions
TDD for joomla extensionsTDD for joomla extensions
TDD for joomla extensionsRoberto Segura
 
PHP - Programming language war, does it matter
PHP - Programming language war, does it matterPHP - Programming language war, does it matter
PHP - Programming language war, does it matterMizno Kruge
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With SeleniumJodie Miners
 
Selenium web driver_2.0_presentation
Selenium web driver_2.0_presentationSelenium web driver_2.0_presentation
Selenium web driver_2.0_presentationsayhi2sudarshan
 
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020Andrew Yatsenko
 
Lighning Talk: PHP build process
Lighning Talk: PHP build processLighning Talk: PHP build process
Lighning Talk: PHP build processBryan Agee
 
Test driven development - Zombie proof your code
Test driven development - Zombie proof your codeTest driven development - Zombie proof your code
Test driven development - Zombie proof your codePascal Larocque
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHPRogério Vicente
 
Test Driven Development (TDD) with Windows PowerShell
Test Driven Development (TDD) with Windows PowerShellTest Driven Development (TDD) with Windows PowerShell
Test Driven Development (TDD) with Windows PowerShellHemmerling
 

Similar a Codeception: introduction to php testing (20)

Joomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation TestingJoomla Code Quality Control and Automation Testing
Joomla Code Quality Control and Automation Testing
 
Continuous Integration In Php
Continuous Integration In PhpContinuous Integration In Php
Continuous Integration In Php
 
Codeception @ New Business Dept Adira Finance
Codeception @ New Business Dept Adira FinanceCodeception @ New Business Dept Adira Finance
Codeception @ New Business Dept Adira Finance
 
[ENGLISH] TDC 2015 - PHP Trail - Tests and PHP Continuous Integration Enviro...
[ENGLISH] TDC 2015 - PHP  Trail - Tests and PHP Continuous Integration Enviro...[ENGLISH] TDC 2015 - PHP  Trail - Tests and PHP Continuous Integration Enviro...
[ENGLISH] TDC 2015 - PHP Trail - Tests and PHP Continuous Integration Enviro...
 
UPC Plone Testing Talk
UPC Plone Testing TalkUPC Plone Testing Talk
UPC Plone Testing Talk
 
Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8
 
Pragmatic Introduction to PHP Unit Testing (2015)
Pragmatic Introduction to PHP Unit Testing (2015)Pragmatic Introduction to PHP Unit Testing (2015)
Pragmatic Introduction to PHP Unit Testing (2015)
 
Behaviour testing for single-page applications and API’s
Behaviour testing for single-page applications and API’sBehaviour testing for single-page applications and API’s
Behaviour testing for single-page applications and API’s
 
Behaviour Testing and Continuous Integration with Drupal
Behaviour Testing and Continuous Integration with DrupalBehaviour Testing and Continuous Integration with Drupal
Behaviour Testing and Continuous Integration with Drupal
 
Continuous Integration at Mollie
Continuous Integration at MollieContinuous Integration at Mollie
Continuous Integration at Mollie
 
TDD for joomla extensions
TDD for joomla extensionsTDD for joomla extensions
TDD for joomla extensions
 
PHP - Programming language war, does it matter
PHP - Programming language war, does it matterPHP - Programming language war, does it matter
PHP - Programming language war, does it matter
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With Selenium
 
Selenium web driver_2.0_presentation
Selenium web driver_2.0_presentationSelenium web driver_2.0_presentation
Selenium web driver_2.0_presentation
 
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
 
Framework
FrameworkFramework
Framework
 
Lighning Talk: PHP build process
Lighning Talk: PHP build processLighning Talk: PHP build process
Lighning Talk: PHP build process
 
Test driven development - Zombie proof your code
Test driven development - Zombie proof your codeTest driven development - Zombie proof your code
Test driven development - Zombie proof your code
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
 
Test Driven Development (TDD) with Windows PowerShell
Test Driven Development (TDD) with Windows PowerShellTest Driven Development (TDD) with Windows PowerShell
Test Driven Development (TDD) with Windows PowerShell
 

Último

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 

Último (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 

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