SlideShare a Scribd company logo
Acceptance & Functional
Testing with Codeception
Joe Ferguson
February 6th 2015
Who Am I?
Joe Ferguson
PHP Developer
Twitter: @JoePFerguson
Organizer of @MemphisPHP
@NomadPHP Lightning Talks
Passionate about Community
One late night coding session
of fighting with tests…
I found
hey, I’m everyone…
Example Test
Sample taken from http://codeception.com
You gotta be…
…me!
Codeception
• Selenium WebDriver integration
• Elements matched by name, CSS, XPath
• Symfony2, Laravel, Yii, Phalcon, Zend Framework
• PageObjects and StepObjects included
• BDD-style readable tests
• Powered by PHPUnit
• API testing: REST,SOAP,XML-RPC
• Facebook API testing
• Data Cleanup
• HTML, XML, TAP, JSON reports
• CodeCoverage and Remote CodeCoverage
• Parallel Execution
Types of Testing
Unit
Functional
Acceptance
Unit Testing
In computer programming, unit testing is a software
testing method by which individual units of source
code, sets of one or more computer program
modules together with associated control data, usage
procedures, and operating procedures, are tested to
determine whether they are fit for use.
https://en.wikipedia.org/wiki/Unit_testing
Functional Testing
Functional testing is a quality assurance (QA) process and a type
of black box testing that bases its test cases on the specifications of
the software component under test. Functions are tested by
feeding them input and examining the output, and internal
program structure is rarely considered (not like in white-box
testing). Functional testing usually describes what the system
does.
Functional testing does not imply that you are testing a function
(method) of your module or class. Functional testing tests a slice
of functionality of the whole system
https://en.wikipedia.org/wiki/Functional_testing
Acceptance Testing
In engineering and its various subdisciplines, acceptance testing is
a test conducted to determine if the requirements of a
specification or contract are met.
In software testing the ISTQB defines acceptance as: formal testing
with respect to user needs, requirements, and business processes
conducted to determine whether or not a system satisfies the
acceptance criteria and to enable the user, customers or other
authorized entity to determine whether or not to accept the
system.
Acceptance testing is also known as user acceptance testing (UAT),
end-user testing, operational acceptance testing (OAT) or field
(acceptance) testing.
https://en.wikipedia.org/wiki/Acceptance_testing
How I think about types
Unit tests test your functions and methods.
Functional tests test parts of your application.
Acceptance tests test your interactions.
Isn’t unit testing enough?
It might be, how high is
your coverage?
How do you know
methods work together?
Functional tests allow you to
test individual scenarios in
your application
Acceptance tests allow you to
test the interactions in your
application
Where do we start?
Install Codeception
Eh…wait a minute…
Better way to install*
*http://blog.doh.ms/2014/10/13/installing-composer-packages
Add to PATH
Bootstrap Codeception
Configure Codeception
Run Codeception
Add Laravel5 Helper
Codecept build
Our First Test
Login Form
Login Form Template
Generate Functional
Test
Writing our test
Click on what?
Click on ‘Copy CSS Path’
How to run tests
codecept run // runs all tests
codecept run functional // run functional tests
codecept run functional tests/functional/
AdminCanLoginCept.php // run single test
Can also add -vv or -vvv for detailed output
Run our test
What are we testing?
The route ‘auth/login’ shows us a login form
Submitting login form performs some action
Dashboard (after successful login) displays
Some success text exists “Hello admin!”
What are we NOT testing?
Navigation on the page
“Remember Me” functionality works
Password Reset works
User is actually an admin
Functional testing tests
a slice of functionality
of the whole system
We don’t care about
Navigation on the page
“Remember Me” functionality works
Password Reset works
User is actually an admin
We care about
$I->wantTo('ensure an admin can log in');
What if our test fails?
Update our password
Run Our test
Failed tests output
Test will pass when…
the user exists in the database
the routes (get & post) work
login form view renders properly
dashboard view renders properly
Framework Modules
Using Laravel5 Module
amOnAction is translated to the /auth/login url
Test Passes
Check the DB for user
seeRecord() will fail if the user does not exist
User is in the database
Check for errors
Useful for checking that error messages are returned
dontSee() ensures text does not exist on view
Testing your API
Generate API Suite
api.suite.yml
Test API Create User
http://codeception.com/docs/10-WebServices
Now we know slices of
our application work
Acceptance Testing
Testing Real(ish) things
Using a real(ish)
browser
Add PhantomJS
Configure
acceptance.suite.yml
Export your Database
php artisan migrate
php artisan db:seed
mysqldump -u homestead -psecret homestead > tests/_data/dump.sql
Our 1st acceptance test
Test passes
That looks a lot like our
functional test!
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Functional Test runs
via PhpBrowser
Acceptance Test runs
via PhantomJS
Testing Elements via
XPath
Use XPath to submit
form
/html/body/div/div/div/div/
div[2]/form/div[4]/div/button
Even more specific
Checking specific
elements
Using XPath for form fields
isn’t very easy to read.
XPath isn’t very easy to
read…
When to use XPath?
When you can’t add an ID or Class on an
element
When you want to ensure styles/formatting
(error messages, flash messages, etc)
When testing navigation elements
When testing any dynamic elements
Acceptance failures
come with screenshots!
Log in and look for
content that doesn’t exist
Test Failed!
We see our content does
not exist on the page
Some issues…
PhantomJS pretty broken on Travis-CI
Acceptance tests are SLOW (and memory hogs)
Acceptance tests aren’t unit tests, it can be hard
to find WHAT is causing the tests to fail
Functional & Acceptance tests aren’t
replacements for unit tests, but can be easier to
write if your app isn’t written to be testable
Codeception Resources
http://www.codeception.com
http://chrislema.com/acceptance-testing-
wordpress-codeception
Writing Acceptance Tests:
https://vimeo.com/113466213
Testing Resources
https://leanpub.com/grumpy-testinghttps://leanpub.com/grumpy-phpunit
http://grumpy-learning.com
Questions?
Feedback!
https://joind.in/talk/4c449
Joe Ferguson
Twitter: @JoePFerguson
Email: joe@joeferguson.me
Freenode: joepferguson
Contact Info:

More Related Content

PDF
Acceptance & Functional Testing with Codeception - Devspace 2015
PDF
Codeception introduction and use in Yii
PDF
Codeception
PPTX
Codeception
PDF
Codeception: introduction to php testing
PDF
Codeception presentation
PDF
From Good to Great: Functional and Acceptance Testing in WordPress.
PPTX
Test automation with php codeception
Acceptance & Functional Testing with Codeception - Devspace 2015
Codeception introduction and use in Yii
Codeception
Codeception
Codeception: introduction to php testing
Codeception presentation
From Good to Great: Functional and Acceptance Testing in WordPress.
Test automation with php codeception

What's hot (20)

PDF
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
PDF
Testing with Codeception
PDF
PHP Unit Testing in Yii
PDF
Acceptance testing in php with Codeception - Techmeetup Edinburgh
PPTX
CI / CD w/ Codeception
PDF
Testing PHP with Codeception
DOCX
Automation Frame works Instruction Sheet
PDF
Mastering Test Automation: How to Use Selenium Successfully
PDF
Unit-testing and E2E testing in JS
PDF
Front-End Testing: Demystified
PDF
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
PDF
Testing Web Applications
PPTX
Automation using Javascript
ODP
Integration Testing in Python
PDF
Testing with Codeception (Webelement #30)
PDF
How To Use Selenium Successfully
PDF
Selenium webdriver interview questions and answers
PDF
Integration testing - A&BP CC
PDF
[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...
PDF
Selenium Automation Testing Interview Questions And Answers
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Testing with Codeception
PHP Unit Testing in Yii
Acceptance testing in php with Codeception - Techmeetup Edinburgh
CI / CD w/ Codeception
Testing PHP with Codeception
Automation Frame works Instruction Sheet
Mastering Test Automation: How to Use Selenium Successfully
Unit-testing and E2E testing in JS
Front-End Testing: Demystified
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Testing Web Applications
Automation using Javascript
Integration Testing in Python
Testing with Codeception (Webelement #30)
How To Use Selenium Successfully
Selenium webdriver interview questions and answers
Integration testing - A&BP CC
[Webinar] Continuous Testing Done Right: Test Automation at the World's Leadi...
Selenium Automation Testing Interview Questions And Answers
Ad

Viewers also liked (15)

PDF
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
PDF
Testing your app with Selenium on Travis CI
PDF
PHP 7 new engine
PPTX
Symfony under control. Continuous Integration and Automated Deployments in Sy...
PPTX
Structural and functional testing
PPTX
Glimpse and Benefits of Testing
PPT
Functional testing
PPTX
Skillwise - 11 cat.ppt
PDF
Re Type Testing
PPTX
Type Cross browsers testing
PDF
Miller using scn egg counts and hg type testing
PPTX
Functional UI Testing
PDF
Type Testing
DOCX
Testing type
PDF
Compatibility Testing
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Testing your app with Selenium on Travis CI
PHP 7 new engine
Symfony under control. Continuous Integration and Automated Deployments in Sy...
Structural and functional testing
Glimpse and Benefits of Testing
Functional testing
Skillwise - 11 cat.ppt
Re Type Testing
Type Cross browsers testing
Miller using scn egg counts and hg type testing
Functional UI Testing
Type Testing
Testing type
Compatibility Testing
Ad

Similar to Acceptance & Functional Testing with Codeception - SunshinePHP 2016 (20)

PPT
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
PPTX
Automated Acceptance Tests & Tool choice
PDF
automation framework
PPT
Stepin evening presented
PPTX
Joomla! Testing - J!DD Germany 2016
PPTX
Mastering Test Automation: How To Use Selenium Successfully
PPTX
Automated Testing Of EPiServer CMS Sites
PPT
Automated Testing Of Web Applications Using XML
PPT
Php Development Stack
PPT
Php Development Stack
PPTX
Automation testing
PPTX
Selenium.pptx
PPTX
Advanced Test Driven-Development @ php[tek] 2024
PDF
Software Quality and Test Strategies for Ruby and Rails Applications
PPTX
Automation testing
PPTX
A Sampling of Tools
PPT
Unit testing php-unit - phing - selenium_v2
PPT
Pragmatic Parallels: Java and JavaScript
PPTX
Test automation lesson
PPT
Getting Started with Apache Jmeter
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Automated Acceptance Tests & Tool choice
automation framework
Stepin evening presented
Joomla! Testing - J!DD Germany 2016
Mastering Test Automation: How To Use Selenium Successfully
Automated Testing Of EPiServer CMS Sites
Automated Testing Of Web Applications Using XML
Php Development Stack
Php Development Stack
Automation testing
Selenium.pptx
Advanced Test Driven-Development @ php[tek] 2024
Software Quality and Test Strategies for Ruby and Rails Applications
Automation testing
A Sampling of Tools
Unit testing php-unit - phing - selenium_v2
Pragmatic Parallels: Java and JavaScript
Test automation lesson
Getting Started with Apache Jmeter

More from Joe Ferguson (20)

PDF
Modern infrastructure as code with ansible cake fest 2021
PDF
Modern infrastructure as code with ansible PyTN
PDF
Slim PHP when you don't need the kitchen sink
PDF
Throwing Laravel into your Legacy App™
PDF
DevSpace Conf 2017 - Making sense of the provisioning circus
PDF
Release and-dependency-management memphis python
PDF
Composer at Scale, Release and Dependency Management
PDF
Put an end to regression with codeception testing
PDF
Midwest PHP 2017 DevOps For Small team
PDF
All the Laravel Things – Up & Running to Making $$
PDF
Console Apps: php artisan forthe:win
PDF
Console Apps: php artisan forthe:win
PDF
All the Laravel things: up and running to making $$
PDF
So You Just Inherited a $Legacy Application… NomadPHP July 2016
PDF
So You Just Inherited a $Legacy Application...
PDF
Laravel Forge: Hello World to Hello Production
PDF
MidwestPHP 2016 - Adventures in Laravel 5
PDF
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
PDF
php[world] 2015 Training - Laravel from the Ground Up
PDF
Madison PHP 2015 - DevOps For Small Teams
Modern infrastructure as code with ansible cake fest 2021
Modern infrastructure as code with ansible PyTN
Slim PHP when you don't need the kitchen sink
Throwing Laravel into your Legacy App™
DevSpace Conf 2017 - Making sense of the provisioning circus
Release and-dependency-management memphis python
Composer at Scale, Release and Dependency Management
Put an end to regression with codeception testing
Midwest PHP 2017 DevOps For Small team
All the Laravel Things – Up & Running to Making $$
Console Apps: php artisan forthe:win
Console Apps: php artisan forthe:win
All the Laravel things: up and running to making $$
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application...
Laravel Forge: Hello World to Hello Production
MidwestPHP 2016 - Adventures in Laravel 5
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
php[world] 2015 Training - Laravel from the Ground Up
Madison PHP 2015 - DevOps For Small Teams

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Approach and Philosophy of On baking technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Spectroscopy.pptx food analysis technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Unlocking AI with Model Context Protocol (MCP)
Reach Out and Touch Someone: Haptics and Empathic Computing
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Review of recent advances in non-invasive hemoglobin estimation
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
NewMind AI Weekly Chronicles - August'25 Week I
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
Advanced methodologies resolving dimensionality complications for autism neur...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Empathic Computing: Creating Shared Understanding
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
sap open course for s4hana steps from ECC to s4
Spectroscopy.pptx food analysis technology
Dropbox Q2 2025 Financial Results & Investor Presentation

Acceptance & Functional Testing with Codeception - SunshinePHP 2016