SlideShare a Scribd company logo
Acceptance & Functional
Testing with Codeception
Joe Ferguson
October 10th 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 and post) work as expected
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 - Devspace 2015
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?

More Related Content

What's hot (20)

PDF
Codeception
Jonathan Lau
 
PPTX
Test automation with php codeception
buddhieash
 
PDF
Testing with Codeception
Jeremy Coates
 
PDF
Acceptance testing in php with Codeception - Techmeetup Edinburgh
Engineor
 
PPTX
CI / CD w/ Codeception
Tudor Barbu
 
PDF
Testing PHP with Codeception
John Paul Ada
 
PDF
Testing Web Applications
Seth McLaughlin
 
PDF
Front-End Testing: Demystified
Seth McLaughlin
 
PDF
Testing with Codeception (Webelement #30)
Adam Štipák
 
PDF
Join the darkside: Selenium testing with Nightwatch.js
Seth McLaughlin
 
PPTX
Automated Testing using JavaScript
Simon Guest
 
PDF
Unit-testing and E2E testing in JS
Michael Haberman
 
PPTX
Automated UI testing done right (DDDSydney)
Mehdi Khalili
 
DOCX
Automation Frame works Instruction Sheet
vodQA
 
PPTX
Browser Automated Testing Frameworks - Nightwatch.js
Luís Bastião Silva
 
PDF
Selenium Basics Tutorial
Clever Moe
 
PPTX
Marcin Wasilczyk - Page objects with selenium
Trójmiejska Grupa Testerska
 
PDF
Lets make a better react form
Yao Nien Chung
 
PDF
Automated Web Testing using JavaScript
Simon Guest
 
PDF
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Applitools
 
Codeception
Jonathan Lau
 
Test automation with php codeception
buddhieash
 
Testing with Codeception
Jeremy Coates
 
Acceptance testing in php with Codeception - Techmeetup Edinburgh
Engineor
 
CI / CD w/ Codeception
Tudor Barbu
 
Testing PHP with Codeception
John Paul Ada
 
Testing Web Applications
Seth McLaughlin
 
Front-End Testing: Demystified
Seth McLaughlin
 
Testing with Codeception (Webelement #30)
Adam Štipák
 
Join the darkside: Selenium testing with Nightwatch.js
Seth McLaughlin
 
Automated Testing using JavaScript
Simon Guest
 
Unit-testing and E2E testing in JS
Michael Haberman
 
Automated UI testing done right (DDDSydney)
Mehdi Khalili
 
Automation Frame works Instruction Sheet
vodQA
 
Browser Automated Testing Frameworks - Nightwatch.js
Luís Bastião Silva
 
Selenium Basics Tutorial
Clever Moe
 
Marcin Wasilczyk - Page objects with selenium
Trójmiejska Grupa Testerska
 
Lets make a better react form
Yao Nien Chung
 
Automated Web Testing using JavaScript
Simon Guest
 
Mastering UI automation at Scale: Key Lessons and Best Practices (By Fernando...
Applitools
 

Similar to Acceptance & Functional Testing with Codeception - Devspace 2015 (20)

PDF
Testing mit Codeception: Full-stack testing PHP framework
SusannSgorzaly
 
PDF
Put an end to regression with codeception testing
Joe Ferguson
 
PDF
Mykhailo Bodnarchuk "The history of the Codeception project"
Fwdays
 
PDF
Codeception: introduction to php testing (v2 - Aberdeen php)
Engineor
 
PDF
Codeception Testing Framework -- English #phpkansai
Florent Batard
 
PPTX
Codeception @ New Business Dept Adira Finance
Fachrul Choliluddin
 
PPTX
Automation testing with Drupal 8
nagpalprachi
 
PPTX
Code ceptioninstallation
Andrii Lagovskiy
 
PDF
WordPress Acceptance Testing, Solved!
Taylor Lovett
 
PPTX
Acceptance testing with codeception
Deniz Zoeteman
 
ODP
Testing in Laravel
Ahmed Yahia
 
PDF
Automatic functional testing easier than you thought Bartosz Cisek
Ireland & UK Moodlemoot 2012
 
PPTX
Laravel Unit Testing
Dr. Syed Hassan Amin
 
PDF
Code Coverage for Total Security in Application Migrations
Dana Luther
 
PDF
Testing in Laravel Framework
Anis Ahmad
 
PDF
Nashville Symfony Functional Testing
Brent Shaffer
 
PDF
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Ondřej Machulda
 
PPTX
Functional tests in_symfony
Sayed Ahmed
 
PDF
Your code are my tests
Michelangelo van Dam
 
PPTX
Automated Testing
Speed FC
 
Testing mit Codeception: Full-stack testing PHP framework
SusannSgorzaly
 
Put an end to regression with codeception testing
Joe Ferguson
 
Mykhailo Bodnarchuk "The history of the Codeception project"
Fwdays
 
Codeception: introduction to php testing (v2 - Aberdeen php)
Engineor
 
Codeception Testing Framework -- English #phpkansai
Florent Batard
 
Codeception @ New Business Dept Adira Finance
Fachrul Choliluddin
 
Automation testing with Drupal 8
nagpalprachi
 
Code ceptioninstallation
Andrii Lagovskiy
 
WordPress Acceptance Testing, Solved!
Taylor Lovett
 
Acceptance testing with codeception
Deniz Zoeteman
 
Testing in Laravel
Ahmed Yahia
 
Automatic functional testing easier than you thought Bartosz Cisek
Ireland & UK Moodlemoot 2012
 
Laravel Unit Testing
Dr. Syed Hassan Amin
 
Code Coverage for Total Security in Application Migrations
Dana Luther
 
Testing in Laravel Framework
Anis Ahmad
 
Nashville Symfony Functional Testing
Brent Shaffer
 
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Ondřej Machulda
 
Functional tests in_symfony
Sayed Ahmed
 
Your code are my tests
Michelangelo van Dam
 
Automated Testing
Speed FC
 
Ad

More from Joe Ferguson (20)

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

Recently uploaded (20)

PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 

Acceptance & Functional Testing with Codeception - Devspace 2015