SlideShare a Scribd company logo
@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

More Related Content

What's hot

HTTP web server 구현
HTTP web server 구현HTTP web server 구현
HTTP web server 구현
Javajigi Jaesung
 
Prometheus - basics
Prometheus - basicsPrometheus - basics
Prometheus - basics
Juraj Hantak
 
React workshop
React workshopReact workshop
React workshop
Imran Sayed
 
JUnit 5
JUnit 5JUnit 5
Message Queuing (MSMQ)
Message Queuing (MSMQ)Message Queuing (MSMQ)
Message Queuing (MSMQ)
Senior Dev
 
React new features and intro to Hooks
React new features and intro to HooksReact new features and intro to Hooks
React new features and intro to Hooks
Soluto
 
React JS & Functional Programming Principles
React JS & Functional Programming PrinciplesReact JS & Functional Programming Principles
React JS & Functional Programming Principles
Andrii Lundiak
 
Easy tests with Selenide and Easyb
Easy tests with Selenide and EasybEasy tests with Selenide and Easyb
Easy tests with Selenide and Easyb
Iakiv Kramarenko
 
Apache Airflow | What Is An Operator
Apache Airflow | What Is An OperatorApache Airflow | What Is An Operator
Apache Airflow | What Is An Operator
Marc Lamberti
 
Curso de WebServlets (Java EE 7)
Curso de WebServlets (Java EE 7)Curso de WebServlets (Java EE 7)
Curso de WebServlets (Java EE 7)
Helder da Rocha
 
Groovy presentation
Groovy presentationGroovy presentation
Groovy presentation
Manav Prasad
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
Aniruddha Chakrabarti
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
Alex Movila
 
Introduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene GraphIntroduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene Graph
ICS
 
React state
React  stateReact  state
React state
Ducat
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
HubSpot
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
Yao Nien Chung
 
Apache Airflow overview
Apache Airflow overviewApache Airflow overview
Apache Airflow overview
NikolayGrishchenkov
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
Qt 5 - C++ and Widgets
Qt 5 - C++ and WidgetsQt 5 - C++ and Widgets
Qt 5 - C++ and Widgets
Juha Peltomäki
 

What's hot (20)

HTTP web server 구현
HTTP web server 구현HTTP web server 구현
HTTP web server 구현
 
Prometheus - basics
Prometheus - basicsPrometheus - basics
Prometheus - basics
 
React workshop
React workshopReact workshop
React workshop
 
JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Message Queuing (MSMQ)
Message Queuing (MSMQ)Message Queuing (MSMQ)
Message Queuing (MSMQ)
 
React new features and intro to Hooks
React new features and intro to HooksReact new features and intro to Hooks
React new features and intro to Hooks
 
React JS & Functional Programming Principles
React JS & Functional Programming PrinciplesReact JS & Functional Programming Principles
React JS & Functional Programming Principles
 
Easy tests with Selenide and Easyb
Easy tests with Selenide and EasybEasy tests with Selenide and Easyb
Easy tests with Selenide and Easyb
 
Apache Airflow | What Is An Operator
Apache Airflow | What Is An OperatorApache Airflow | What Is An Operator
Apache Airflow | What Is An Operator
 
Curso de WebServlets (Java EE 7)
Curso de WebServlets (Java EE 7)Curso de WebServlets (Java EE 7)
Curso de WebServlets (Java EE 7)
 
Groovy presentation
Groovy presentationGroovy presentation
Groovy presentation
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Introduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene GraphIntroduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene Graph
 
React state
React  stateReact  state
React state
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
Lets make a better react form
Lets make a better react formLets make a better react form
Lets make a better react form
 
Apache Airflow overview
Apache Airflow overviewApache Airflow overview
Apache Airflow overview
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Qt 5 - C++ and Widgets
Qt 5 - C++ and WidgetsQt 5 - C++ and Widgets
Qt 5 - C++ and Widgets
 

Similar to Testing with Codeception

Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHP
Marcos Quesada
 
2012 04-19 theory-of_operation
2012 04-19 theory-of_operation2012 04-19 theory-of_operation
2012 04-19 theory-of_operation
bobwolff68
 
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 applications
Evgeniy Kuzmin
 
Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous delivery
EatDog
 
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
François-Xavier Bonnet
 
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
DONGJOO HA
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.js
Ryan Anklam
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
Troy Miles
 
Frontend microservices: architectures and solutions
Frontend microservices: architectures and solutionsFrontend microservices: architectures and solutions
Frontend microservices: architectures and solutions
Mikhail Kuznetcov
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
Sapna 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 Default
JSFestUA
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
David 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 2
Andrew 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 frontend
Vlad 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 applications
Andrew 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 Interactive
John 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 2017
Matt 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
 

Similar to 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
 

More from Jeremy Coates

Cyber Security and GDPR
Cyber Security and GDPRCyber Security and GDPR
Cyber Security and GDPR
Jeremy Coates
 
Aspect Oriented Programming
Aspect Oriented ProgrammingAspect Oriented Programming
Aspect Oriented Programming
Jeremy Coates
 
Why is PHP Awesome
Why is PHP AwesomeWhy is PHP Awesome
Why is PHP Awesome
Jeremy 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 system
Jeremy Coates
 
Insects in your mind
Insects in your mindInsects in your mind
Insects in your mind
Jeremy Coates
 
Phing
PhingPhing
Hudson Continuous Integration for PHP
Hudson Continuous Integration for PHPHudson Continuous Integration for PHP
Hudson Continuous Integration for PHP
Jeremy Coates
 
The Uncertainty Principle
The Uncertainty PrincipleThe Uncertainty Principle
The Uncertainty Principle
Jeremy Coates
 
Exploiting Php With Php
Exploiting Php With PhpExploiting Php With Php
Exploiting Php With Php
Jeremy 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.3
Jeremy Coates
 
Kiss Phpnw08
Kiss Phpnw08Kiss Phpnw08
Kiss Phpnw08
Jeremy Coates
 
Regex Basics
Regex BasicsRegex Basics
Regex Basics
Jeremy Coates
 
Search Lucene
Search LuceneSearch Lucene
Search Lucene
Jeremy Coates
 
Mysql Explain Explained
Mysql Explain ExplainedMysql Explain Explained
Mysql Explain Explained
Jeremy Coates
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version Control
Jeremy Coates
 
PHPNW Conference Update
PHPNW Conference UpdatePHPNW Conference Update
PHPNW Conference Update
Jeremy Coates
 

More from 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
 

Recently uploaded

A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 

Recently uploaded (20)

A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 

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