SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
@magma_digital
RefactorGreen
Testing with Codeception
Jeremy Coates / @phpcodemonkey
Red
@magma_digital
Who am I?
๏ Jeremy Coates, CEO at Magma Digital Ltd
๏ Founder of PHPNW
๏ Lancashire Digital CIC founding director
๏ @phpcodemonkey
๏ linkedin.com/in/jeremycoates
@magma_digital
What is Codeception?
A new powerful testing framework written in PHP, using Symfony2
Components, PHPUnit & Behat's Mink drivers (for wire protocol).
In the words of Codeception:
Codeception is a BDD-styled PHP testing
framework, whose only requirements are
basic knowledge of PHP and the theory of
automated testing. Codeception is kept as
simple as possible for any kind of users.
“
@magma_digital
Codeception:
๏ Is easy to read / write / debug
๏ Enables users with different roles to share common
test language
๏ Integrates with
IDE code completion
๏ Describes actions from
a users point of view
๏ Makes testing fun!
The Pitch
@magma_digital
You can test your applications, through multiple approaches:
๏ Unit Tests
๏ Functional Tests
๏ Acceptance Tests
๏ API Tests
๏ Database Repopulation
Focus on Acceptance / Functional / Db
What Does Codeception Do?
5 of 46
@magma_digital
Codeception Features (1)
๏ Multiple backends, easily changed in configuration
- Selenium, PhpBrowser, ZombieJS, PhantomJS*
๏ Elements matched by Name, CSS, XPath
๏ Data Cleanup after each run
๏ Integrate with
- Symfony2, Zend Framework, Kohana, Yii, Laravel etc.
๏ Continuous Integration systems like Jenkins or Bamboo
@magma_digital
Codeception Features (2)
๏ Natively executes PHPUnit tests
๏ BDD-style scenario-driven tests
๏ WebServices testing via REST,
SOAP, XML-RPC
๏ Generates HTML, XML, TAP, JSON reports
๏ Simple Fixtures (known test data)
๏ Database and Doctrine ORM helpers
๏ CodeCoverage and Remote CodeCoverage
@magma_digital
Codeception Modules
Modules extend the connectivity and
therefore the things you can test with
Codeception - additional methods for
the $I object.
This is the current released set of
modules, however new ones are
being created with regularity e.g.
ZF2 has recently been accepted
as a module.
@magma_digital
Codeception utilises:
๏ Symfony2 Components
๏ PHPUnit
๏ Behat's Mink drivers
๏ Facebook webdriver
- for wire protocol
License:
๏ MIT Licence
What You Need to Know?
Requires:
๏ PHP 5.3+ (v1.x)
๏ CURL enabled
Developed by:
๏ Michael Bodnarchuk @davert,
based in Kiev, Ukraine runs
outsourcing company Codegyre
๏ Sponsored by 2amigOS! Since
June 2013 (sponsors of Yii)
@magma_digital
๏ Browser emulation (Mink / Selenium / WebDriver)
๏ Test any website
๏ Test JavaScript & Ajax
๏ Readable by humans (managers!)
๏ Stability against code changes
๏ Some false positives
๏ SLOW!
Acceptance vs Functional vs Unit
@magma_digital
Acceptance vs Functional vs Unit
๏ Emulate web request & submit to application
๏ Assert against response & query internal values
๏ Framework based
๏ Still readable by humans
๏ Can't test JS/Ajax
๏ Risk of false positives
๏ Less slow
@magma_digital
Acceptance vs Functional vs Unit
๏ Runs on top of PHPUnit with bells & whistles
๏ Tests feel simpler / cleaner
๏ Not readable by humans
๏ Test application core
๏ Isolated units
๏ Fastest
@magma_digital
Codeception: Howto?
๏ bootstrap - set up test folder & base files
๏ configure - to suit how you want to test
๏ build - when add suite, automatic otherwise
๏ generate:cept generate:test generate:phpunit
generate:scenarios <suite> <test>
๏ Write test - unfortunately you still have to do
this bit!
๏ run --steps --debug --silent --report --coverage
--html --xml --json [<suite>] [<test>]
@magma_digital
Naysayers?
๏I don't need no stinking tests!
๏I already use PHPUnit, why
switch?
๏I Behat now, why write things
only once?
๏I already use Selenium (with
PHPUnit), why change?
๏What's all this Guy business
about?
Don’t need it,
not listening !
@magma_digital
Installation - Phar
๏Phar file installation is the preferred method
๏Grab Codeception phar executable:
- wget http://codeception.com/codecept.phar -O codecept.phar
๏Prepare tests directory and configs:
- php codecept.phar bootstrap
@magma_digital
Installation - Composer
๏ Install Composer as normal:
- curl -sS https://getcomposer.org/installer | php
๏Add Codeception to composer.json:
- php composer.phar require “codeception/codeception:@stable”
๏Run Codeception from vendor path
- vendor/bin/codecept bootstrap
@magma_digital
Advanced Usage (1)
๏ Helpers - simply add Actions to your Guys
๏ Groups - put tests into groups and provide hooks for them
- $scenario->group(<groupname>) $scenario-
>group(array(<groupname>, <groupname>))
- run --group <groupname> (or -g)
๏ Console - interactive console, try commands without tests
๏ Config Reconfigure - dynamically change module config (from helpers
->_reconfigure(array(‘browser’ => ‘chrome’)); )
๏ Stubs - mocking code Stub::makeEmpty (see also AspectMock
framework)
@magma_digital
Advanced Usage (2)
๏ PageObjects - new classes for defining UI maps
๏ StepObjects - common actions used in different tests
๏ Events - fire at various points during test execution
๏ Extension & Group classes that can hook into events and produce
their own. Extend anything
๏ Conditional Asserts - don’t stop a test if assert fails
- each ‘see’ method has ‘canSee’ equivalent
- each ‘dontSee’ method has ‘cantSee’ equivalent
๏ Comments - $I[‘describe everything in comments and then automate’];
@magma_digital
๏ Codeception 2.0 (June ’14):
- Removed Mink - replace with WebDriver module (Facebook API)
- Tests not executed twice as previous
- PHP 5.4+
- No Guys, new folder structure _log -> _output, _helpers -> _support
- Remove: Selenium/2, ZombieJS -> WebDriver (Facebook API)
- Updated dependencies - e.g. Guzzle 4
- No BC breaks? :)
Roadmap(Achieved)
@magma_digital
๏ Codeception 2.1 (April ’15):
- PSR-4 Support - test/_support - new location for all support code
- *Tester classes generated once - traits for common code, customise :)
- Dependency Injection - page/step objects, modules -> helpers
- Simplified config - specify helpers in config
- Environment Matrix - tests/_envs folder. codecept run —env dev,chrome
- Module Parts - pic’n’mix partial loading of actions
- WebDriver - session snapshots - skip logging in every time!
- No major BC breaks? :)
Roadmap(Next)
@magma_digital
Codeception: Add-ons
๏ http://codeception.com/addons - useful add-ons, not core
to Codeception
๏ WebCeption (Application): web front end for Codeception
๏ VisualCeption (Module): visual regression tests
๏ DrushDb (Extension): populate/clean up Drupal site with
drush / sql-sync during test runs
๏ RemoteDebug (Extension): code coverage from remote
sites
@magma_digital
Resources
๏ Codeception: http://codeception.com/
๏ Codeception Github: http://github.com/codeception/Codeception/
๏ Composer: http://getcomposer.org/
๏ Selenium WebDriver: http://docs.seleniumhq.org/download/
๏ ChromeDriver: http://code.google.com/p/chromedriver/
๏ GhostDriver: https://github.com/detro/ghostdriver (now part of PhantomJS)
๏ PhantomJS: http://phantomjs.org/
๏ Netbeans IDE: http://netbeans.org/downloads/
๏ WebDriver Wire Protocol:
- http://code.google.com/p/selenium/wiki/JsonWireProtocol
@magma_digital
๏ Jeremy Coates, CEO at Magma Digital Ltd
๏ Founder of PHPNW
๏ Lancashire Digital CIC founding director
๏ @phpcodemonkey
๏ linkedin.com/in/jeremycoates
Now Get Testing...
DownloadSlides Here!
http://bit.ly/test_with_codeception

Weitere ähnliche Inhalte

Was ist angesagt?

OWASP API Security Top 10 Examples
OWASP API Security Top 10 ExamplesOWASP API Security Top 10 Examples
OWASP API Security Top 10 Examples42Crunch
 
Rest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API SecurityRest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API SecurityMohammed Fazuluddin
 
B4USolution_API-Testing
B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testingb4usolution .
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring BootTrey Howard
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - APIChetan Gadodia
 
React for Dummies
React for DummiesReact for Dummies
React for DummiesMitch Chen
 
API Test Automation
API Test Automation API Test Automation
API Test Automation SQALab
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016Frans Rosén
 
The Power Of Composition (DotNext 2019)
The Power Of Composition (DotNext 2019)The Power Of Composition (DotNext 2019)
The Power Of Composition (DotNext 2019)Scott Wlaschin
 
Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practicesAnkita Mahajan
 
SSRF For Bug Bounties
SSRF For Bug BountiesSSRF For Bug Bounties
SSRF For Bug BountiesOWASP Nagpur
 
Types of sql injection attacks
Types of sql injection attacksTypes of sql injection attacks
Types of sql injection attacksRespa Peter
 

Was ist angesagt? (20)

OWASP API Security Top 10 Examples
OWASP API Security Top 10 ExamplesOWASP API Security Top 10 Examples
OWASP API Security Top 10 Examples
 
Rest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API SecurityRest API Security - A quick understanding of Rest API Security
Rest API Security - A quick understanding of Rest API Security
 
B4USolution_API-Testing
B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testing
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
 
Clean code
Clean codeClean code
Clean code
 
Php basics
Php basicsPhp basics
Php basics
 
React for Dummies
React for DummiesReact for Dummies
React for Dummies
 
Benefits of developing single page web applications using angular js
Benefits of developing single page web applications using angular jsBenefits of developing single page web applications using angular js
Benefits of developing single page web applications using angular js
 
API Test Automation
API Test Automation API Test Automation
API Test Automation
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
 
Api testing
Api testingApi testing
Api testing
 
Unit Test
Unit TestUnit Test
Unit Test
 
API Testing for everyone.pptx
API Testing for everyone.pptxAPI Testing for everyone.pptx
API Testing for everyone.pptx
 
The Power Of Composition (DotNext 2019)
The Power Of Composition (DotNext 2019)The Power Of Composition (DotNext 2019)
The Power Of Composition (DotNext 2019)
 
Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practices
 
SSRF For Bug Bounties
SSRF For Bug BountiesSSRF For Bug Bounties
SSRF For Bug Bounties
 
Types of sql injection attacks
Types of sql injection attacksTypes of sql injection attacks
Types of sql injection attacks
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
NestJS
NestJSNestJS
NestJS
 

Ähnlich wie Testing with Codeception

Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHPMarcos Quesada
 
2012 04-19 theory-of_operation
2012 04-19 theory-of_operation2012 04-19 theory-of_operation
2012 04-19 theory-of_operationbobwolff68
 
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...Evgeniy Kuzmin
 
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applicationsContinuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applicationsEvgeniy Kuzmin
 
Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous deliveryEatDog
 
BinProxy: New Paradigm of Binary Analysis With Your Favorite Web Proxy
BinProxy: New Paradigm of Binary Analysis With Your Favorite Web ProxyBinProxy: New Paradigm of Binary Analysis With Your Favorite Web Proxy
BinProxy: New Paradigm of Binary Analysis With Your Favorite Web ProxyDONGJOO HA
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.jsRyan Anklam
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy Miles
 
Frontend microservices: architectures and solutions
Frontend microservices: architectures and solutionsFrontend microservices: architectures and solutions
Frontend microservices: architectures and solutionsMikhail Kuznetcov
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteorSapna Upreti
 
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by DefaultJS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by DefaultJSFestUA
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationDavid Amend
 
Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Andrew Yatsenko
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendVlad Fedosov
 
Go Pro, Inc. Case Study: Dive into the details of our node.js applications
Go Pro, Inc. Case Study: Dive into the details of our node.js applicationsGo Pro, Inc. Case Study: Dive into the details of our node.js applications
Go Pro, Inc. Case Study: Dive into the details of our node.js applicationsAndrew Maxwell
 
Introduction to Web Components & Polymer Workshop - JS Interactive
Introduction to Web Components & Polymer Workshop - JS InteractiveIntroduction to Web Components & Polymer Workshop - JS Interactive
Introduction to Web Components & Polymer Workshop - JS InteractiveJohn Riviello
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JSFestUA
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Matt Raible
 
Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer John Riviello
 

Ähnlich wie Testing with Codeception (20)

Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHP
 
2012 04-19 theory-of_operation
2012 04-19 theory-of_operation2012 04-19 theory-of_operation
2012 04-19 theory-of_operation
 
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
 
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applicationsContinuous Integration/ Continuous Delivery of web applications
Continuous Integration/ Continuous Delivery of web applications
 
Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous delivery
 
ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013ESIGate dev meeting #4 21-11-2013
ESIGate dev meeting #4 21-11-2013
 
BinProxy: New Paradigm of Binary Analysis With Your Favorite Web Proxy
BinProxy: New Paradigm of Binary Analysis With Your Favorite Web ProxyBinProxy: New Paradigm of Binary Analysis With Your Favorite Web Proxy
BinProxy: New Paradigm of Binary Analysis With Your Favorite Web Proxy
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.js
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
Frontend microservices: architectures and solutions
Frontend microservices: architectures and solutionsFrontend microservices: architectures and solutions
Frontend microservices: architectures and solutions
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by DefaultJS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
JS Fest 2019. Minko Gechev. Building Fast Angular Applications by Default
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
 
Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontend
 
Go Pro, Inc. Case Study: Dive into the details of our node.js applications
Go Pro, Inc. Case Study: Dive into the details of our node.js applicationsGo Pro, Inc. Case Study: Dive into the details of our node.js applications
Go Pro, Inc. Case Study: Dive into the details of our node.js applications
 
Introduction to Web Components & Polymer Workshop - JS Interactive
Introduction to Web Components & Polymer Workshop - JS InteractiveIntroduction to Web Components & Polymer Workshop - JS Interactive
Introduction to Web Components & Polymer Workshop - JS Interactive
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
 
Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017Front End Development for Back End Developers - UberConf 2017
Front End Development for Back End Developers - UberConf 2017
 
Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer
 

Mehr von Jeremy Coates

Cyber Security and GDPR
Cyber Security and GDPRCyber Security and GDPR
Cyber Security and GDPRJeremy Coates
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented ProgrammingJeremy Coates
 
An introduction to Phing the PHP build system (PHPDay, May 2012)
An introduction to Phing the PHP build system (PHPDay, May 2012)An introduction to Phing the PHP build system (PHPDay, May 2012)
An introduction to Phing the PHP build system (PHPDay, May 2012)Jeremy Coates
 
An introduction to Phing the PHP build system
An introduction to Phing the PHP build systemAn introduction to Phing the PHP build system
An introduction to Phing the PHP build systemJeremy Coates
 
Insects in your mind
Insects in your mindInsects in your mind
Insects in your mindJeremy Coates
 
Hudson Continuous Integration for PHP
Hudson Continuous Integration for PHPHudson Continuous Integration for PHP
Hudson Continuous Integration for PHPJeremy Coates
 
The Uncertainty Principle
The Uncertainty PrincipleThe Uncertainty Principle
The Uncertainty PrincipleJeremy Coates
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With PhpJeremy Coates
 
What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3Jeremy Coates
 
Mysql Explain Explained
Mysql Explain ExplainedMysql Explain Explained
Mysql Explain ExplainedJeremy Coates
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version ControlJeremy Coates
 
PHPNW Conference Update
PHPNW Conference UpdatePHPNW Conference Update
PHPNW Conference UpdateJeremy Coates
 

Mehr von Jeremy Coates (17)

Cyber Security and GDPR
Cyber Security and GDPRCyber Security and GDPR
Cyber Security and GDPR
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
 
Why is PHP Awesome
Why is PHP AwesomeWhy is PHP Awesome
Why is PHP Awesome
 
An introduction to Phing the PHP build system (PHPDay, May 2012)
An introduction to Phing the PHP build system (PHPDay, May 2012)An introduction to Phing the PHP build system (PHPDay, May 2012)
An introduction to Phing the PHP build system (PHPDay, May 2012)
 
An introduction to Phing the PHP build system
An introduction to Phing the PHP build systemAn introduction to Phing the PHP build system
An introduction to Phing the PHP build system
 
Insects in your mind
Insects in your mindInsects in your mind
Insects in your mind
 
Phing
PhingPhing
Phing
 
Hudson Continuous Integration for PHP
Hudson Continuous Integration for PHPHudson Continuous Integration for PHP
Hudson Continuous Integration for PHP
 
The Uncertainty Principle
The Uncertainty PrincipleThe Uncertainty Principle
The Uncertainty Principle
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With Php
 
What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3
 
Kiss Phpnw08
Kiss Phpnw08Kiss Phpnw08
Kiss Phpnw08
 
Regex Basics
Regex BasicsRegex Basics
Regex Basics
 
Search Lucene
Search LuceneSearch Lucene
Search Lucene
 
Mysql Explain Explained
Mysql Explain ExplainedMysql Explain Explained
Mysql Explain Explained
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version Control
 
PHPNW Conference Update
PHPNW Conference UpdatePHPNW Conference Update
PHPNW Conference Update
 

Kürzlich hochgeladen

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 

Kürzlich hochgeladen (20)

The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

Testing with Codeception

  • 2. @magma_digital Who am I? ๏ Jeremy Coates, CEO at Magma Digital Ltd ๏ Founder of PHPNW ๏ Lancashire Digital CIC founding director ๏ @phpcodemonkey ๏ linkedin.com/in/jeremycoates
  • 3. @magma_digital What is Codeception? A new powerful testing framework written in PHP, using Symfony2 Components, PHPUnit & Behat's Mink drivers (for wire protocol). In the words of Codeception: Codeception is a BDD-styled PHP testing framework, whose only requirements are basic knowledge of PHP and the theory of automated testing. Codeception is kept as simple as possible for any kind of users. “
  • 4. @magma_digital Codeception: ๏ Is easy to read / write / debug ๏ Enables users with different roles to share common test language ๏ Integrates with IDE code completion ๏ Describes actions from a users point of view ๏ Makes testing fun! The Pitch
  • 5. @magma_digital You can test your applications, through multiple approaches: ๏ Unit Tests ๏ Functional Tests ๏ Acceptance Tests ๏ API Tests ๏ Database Repopulation Focus on Acceptance / Functional / Db What Does Codeception Do? 5 of 46
  • 6. @magma_digital Codeception Features (1) ๏ Multiple backends, easily changed in configuration - Selenium, PhpBrowser, ZombieJS, PhantomJS* ๏ Elements matched by Name, CSS, XPath ๏ Data Cleanup after each run ๏ Integrate with - Symfony2, Zend Framework, Kohana, Yii, Laravel etc. ๏ Continuous Integration systems like Jenkins or Bamboo
  • 7. @magma_digital Codeception Features (2) ๏ Natively executes PHPUnit tests ๏ BDD-style scenario-driven tests ๏ WebServices testing via REST, SOAP, XML-RPC ๏ Generates HTML, XML, TAP, JSON reports ๏ Simple Fixtures (known test data) ๏ Database and Doctrine ORM helpers ๏ CodeCoverage and Remote CodeCoverage
  • 8. @magma_digital Codeception Modules Modules extend the connectivity and therefore the things you can test with Codeception - additional methods for the $I object. This is the current released set of modules, however new ones are being created with regularity e.g. ZF2 has recently been accepted as a module.
  • 9. @magma_digital Codeception utilises: ๏ Symfony2 Components ๏ PHPUnit ๏ Behat's Mink drivers ๏ Facebook webdriver - for wire protocol License: ๏ MIT Licence What You Need to Know? Requires: ๏ PHP 5.3+ (v1.x) ๏ CURL enabled Developed by: ๏ Michael Bodnarchuk @davert, based in Kiev, Ukraine runs outsourcing company Codegyre ๏ Sponsored by 2amigOS! Since June 2013 (sponsors of Yii)
  • 10. @magma_digital ๏ Browser emulation (Mink / Selenium / WebDriver) ๏ Test any website ๏ Test JavaScript & Ajax ๏ Readable by humans (managers!) ๏ Stability against code changes ๏ Some false positives ๏ SLOW! Acceptance vs Functional vs Unit
  • 11. @magma_digital Acceptance vs Functional vs Unit ๏ Emulate web request & submit to application ๏ Assert against response & query internal values ๏ Framework based ๏ Still readable by humans ๏ Can't test JS/Ajax ๏ Risk of false positives ๏ Less slow
  • 12. @magma_digital Acceptance vs Functional vs Unit ๏ Runs on top of PHPUnit with bells & whistles ๏ Tests feel simpler / cleaner ๏ Not readable by humans ๏ Test application core ๏ Isolated units ๏ Fastest
  • 13. @magma_digital Codeception: Howto? ๏ bootstrap - set up test folder & base files ๏ configure - to suit how you want to test ๏ build - when add suite, automatic otherwise ๏ generate:cept generate:test generate:phpunit generate:scenarios <suite> <test> ๏ Write test - unfortunately you still have to do this bit! ๏ run --steps --debug --silent --report --coverage --html --xml --json [<suite>] [<test>]
  • 14. @magma_digital Naysayers? ๏I don't need no stinking tests! ๏I already use PHPUnit, why switch? ๏I Behat now, why write things only once? ๏I already use Selenium (with PHPUnit), why change? ๏What's all this Guy business about? Don’t need it, not listening !
  • 15. @magma_digital Installation - Phar ๏Phar file installation is the preferred method ๏Grab Codeception phar executable: - wget http://codeception.com/codecept.phar -O codecept.phar ๏Prepare tests directory and configs: - php codecept.phar bootstrap
  • 16. @magma_digital Installation - Composer ๏ Install Composer as normal: - curl -sS https://getcomposer.org/installer | php ๏Add Codeception to composer.json: - php composer.phar require “codeception/codeception:@stable” ๏Run Codeception from vendor path - vendor/bin/codecept bootstrap
  • 17. @magma_digital Advanced Usage (1) ๏ Helpers - simply add Actions to your Guys ๏ Groups - put tests into groups and provide hooks for them - $scenario->group(<groupname>) $scenario- >group(array(<groupname>, <groupname>)) - run --group <groupname> (or -g) ๏ Console - interactive console, try commands without tests ๏ Config Reconfigure - dynamically change module config (from helpers ->_reconfigure(array(‘browser’ => ‘chrome’)); ) ๏ Stubs - mocking code Stub::makeEmpty (see also AspectMock framework)
  • 18. @magma_digital Advanced Usage (2) ๏ PageObjects - new classes for defining UI maps ๏ StepObjects - common actions used in different tests ๏ Events - fire at various points during test execution ๏ Extension & Group classes that can hook into events and produce their own. Extend anything ๏ Conditional Asserts - don’t stop a test if assert fails - each ‘see’ method has ‘canSee’ equivalent - each ‘dontSee’ method has ‘cantSee’ equivalent ๏ Comments - $I[‘describe everything in comments and then automate’];
  • 19. @magma_digital ๏ Codeception 2.0 (June ’14): - Removed Mink - replace with WebDriver module (Facebook API) - Tests not executed twice as previous - PHP 5.4+ - No Guys, new folder structure _log -> _output, _helpers -> _support - Remove: Selenium/2, ZombieJS -> WebDriver (Facebook API) - Updated dependencies - e.g. Guzzle 4 - No BC breaks? :) Roadmap(Achieved)
  • 20. @magma_digital ๏ Codeception 2.1 (April ’15): - PSR-4 Support - test/_support - new location for all support code - *Tester classes generated once - traits for common code, customise :) - Dependency Injection - page/step objects, modules -> helpers - Simplified config - specify helpers in config - Environment Matrix - tests/_envs folder. codecept run —env dev,chrome - Module Parts - pic’n’mix partial loading of actions - WebDriver - session snapshots - skip logging in every time! - No major BC breaks? :) Roadmap(Next)
  • 21. @magma_digital Codeception: Add-ons ๏ http://codeception.com/addons - useful add-ons, not core to Codeception ๏ WebCeption (Application): web front end for Codeception ๏ VisualCeption (Module): visual regression tests ๏ DrushDb (Extension): populate/clean up Drupal site with drush / sql-sync during test runs ๏ RemoteDebug (Extension): code coverage from remote sites
  • 22. @magma_digital Resources ๏ Codeception: http://codeception.com/ ๏ Codeception Github: http://github.com/codeception/Codeception/ ๏ Composer: http://getcomposer.org/ ๏ Selenium WebDriver: http://docs.seleniumhq.org/download/ ๏ ChromeDriver: http://code.google.com/p/chromedriver/ ๏ GhostDriver: https://github.com/detro/ghostdriver (now part of PhantomJS) ๏ PhantomJS: http://phantomjs.org/ ๏ Netbeans IDE: http://netbeans.org/downloads/ ๏ WebDriver Wire Protocol: - http://code.google.com/p/selenium/wiki/JsonWireProtocol
  • 23. @magma_digital ๏ Jeremy Coates, CEO at Magma Digital Ltd ๏ Founder of PHPNW ๏ Lancashire Digital CIC founding director ๏ @phpcodemonkey ๏ linkedin.com/in/jeremycoates Now Get Testing... DownloadSlides Here! http://bit.ly/test_with_codeception