SlideShare a Scribd company logo
1 of 27
Download to read offline
WordPress Acceptance
Testing: Solved!
https://github.com/10up/wpacceptance
What Is the Purpose of Automated
Testing?
• Testing helps us reduce bugs/regressions and
ensures our application meets requirements.
• Manual testing, while also useful and important,
is slow, expensive, and prone to human error.
• Automated testing can be integrated such that it
is run continuously e.g. part of a development
and delivery pipeline.
Types of Automated Testing
• There are many different types of automated
testing: unit, functional, performance,
acceptance/end-to-end, integration, etc.
• WordPress bundles integration/unit tests as well
as end to end tests for certain features.
Automated Testing Tools
• WordPress PHPUnit Test Suite - the framework used
by core and one you can include in plugins/themes to
write integration tests. Based on PHPUnit.
• WP Mock - a project started by 10up for writing true
unit tests for WordPress. Also based on PHPUnit.
• A number of acceptance testing frameworks e.g.
Codeception. Custom built ones e.g. Gutenberg’s
end-to-end testing system.
• JS testing frameworks
What Is Acceptance Testing?
• Acceptance testing is testing that an application
behaves as expected.
• In the web application world, this usually means
simulating a real user interacting with a web
application via a browser.
The Problem
• Acceptance testing is challenging because
everyone and every system (CI) running the
tests must be running the tests against the same
codebase, environment, and database.
The Problem (cont.)
• Codeception is a popular PHP framework for writing acceptance
tests. The framework does not bundle any functionality around the
environment or database sharing.
• Different engineers on the team often run different local
environments leading to test inconsistencies.
• When an engineer runs the tests on their local, the tests are run
against their local database. Different members of the
engineering team have different local databases and it is tough
to keep everyone in sync.
• To make this work with CI you’d have to create a way for your CI
tool to start a web environment and pass it predefined database
exports.
https://codeception.com
WP Acceptance Overview
• WP Acceptance is a toolkit that empowers
developers and CI pipelines to test codebases
using version controlled acceptance tests and
sharable environments.
https://github.com/10up/wpacceptance
What Makes WP Acceptance Powerful?
• WP Acceptance lets you create environment
instructions to be version controlled with your
tests. Every time you, a team member, or a CI
pipeline run the tests, an environment will be
created from those instructions guaranteeing the
same results for everyone.
Environment Instructions
• Environment instructions look like this:

install wordpress where version is latest and url is http://url.test



activate plugin where name is safe-redirect-manager

install theme where name is twentynineteen



create post where title is Test and content is “Test content”
Read about supported instructions: https://github.com/10up/wpinstructions
wpacceptance.json
• All WP Acceptance projects contain a file named
wpacceptance.json. Here’s an example:
{
"name": "10up-experience",
"exclude": [
"node_modules"
],
"tests": [
"./tests/wpa/*.php"
],
"enforce_clean_db": false,
"project_path": "%WP_ROOT%/wp-content/plugins/10up-experience",
[
"install wordpress where url is http://10upexperience.test",
"activate plugin where name is 10up-experience",
"install theme where name is twentynineteen"
]
]
}
Snapshots
• Sometimes you need to test in a complex
environment e.g. you are building a site with 30
plugins and large database for a client.
• For this, you will want to use a Snapshot. WP
Acceptance lets you run your tests on
Environment Instructions or Snapshot(s).
• Snapshots are based on the WP Snapshots
project: https://github.com/10up/wpsnapshots
Snapshots (cont.)
• In the snapshot workflow you will need to prepare a
“primary” snapshot for the development team to use.
• You can run WPA against your local environment and save
the snapshot:

wpacceptance run --local --save_snapshot
• This will update your wpacceptance.json file with the new
snapshot ID so other developers/CI can use that
snapshot.
• When major changes are made to the site e.g. new
content types, you will want to create a new snapshot.
wpacceptance.json
• Here’s a wpacceptance.json file using WP
Snapshots:
{
“name": "distributor",
"exclude": [
"./node_modules"
],
"tests": [
"tests/wpacceptance/*Test.php"
],
"snapshots": [
{
"snapshot_name": "WordPress 5.1.1",
"snapshot_id": "fec81ac24227af6554c93d28d9af2bdf"
}
],
"enforce_clean_db": true,
"bootstrap": "tests/wpacceptance/bootstrap.php",
"repository": "10up"
}
Install and Usage
• WP Acceptance is added to a project via
Composer. You can use it on a theme, plugin, or
in any WordPress application.
• Step 1: composer require 10up/wpacceptance
• Step 2: Create your wpacceptance.json file (or
run ./vendor/bin/wpacceptance init)
• Step 3: ./vendor/bin/wpacceptance run
A Simple Test
You can see a test lets us
interact with the website as
a user.
If “Modal Title” is not visible
after clicking .modal-link,
the test will fail.
$I = $this->openBrowserPage();

$I->moveTo( '/' );

$I->click( 'a.modal-link' );

$I->seeText( 'Modal Title' );
Testing the Admin
$I = $this->openBrowserPage();

$I->login();

$I->moveTo( '/wp-admin/profile.php' );

$I->waitUntilElementVisible( '#wpadminbar' );

$I->fillField( '#first_name', 'Test Name' );

$I->click( '#submit' );

$I->waitUntilElementVisible( '#wpadminbar' );

$I->seeValueInAttribute( '#first_name', 'value', 'Test Name',
'Profile field did not update.' );
Saving a Post
$I = $this->openBrowserPage();
$I->loginAs( 'admin' );
$I->moveTo( 'wp-admin/post-new.php?post_type=redirect_rule' );
$I->fillField( '#srm_redirect_rule_from', '/test' );
$I->fillField( '#srm_redirect_rule_to', '/test2' );
$I->fillField( '#srm_redirect_rule_notes', 'Notes' );
$I->click( '#publish' );
$I->waitUntilElementVisible( '.updated' );
$I->seeValueInProperty( '#srm_redirect_rule_from', 'value', '/test' );
$I->seeValueInProperty( '#srm_redirect_rule_to', 'value', '/test2' );
$I->seeValueInProperty( '#srm_redirect_rule_notes', 'value', 'Notes' );
(From Safe Redirect Manager)
Standard Test Suite
• WP Acceptance includes standard tests that you
can include in any test suite
• The standard tests ensure basic functionality is
working. This is useful as often times while
building plugins and themes we can break
things and not know about it.
Standard Test Suite
• Test the front end loads properly.
• Test that an admin can create a post.
• Test the admin bar is showing.
• Test users can update their profile.
• Test users can update general settings.
• Etc.
Standard Test Suite
class MyTests extends WPAcceptancePHPUnitTestCase {
/**
* @testdox I can log in.
*/
public function testLogin() {
parent::_testLogin();
}
}
Continuous Integration
• WP Acceptance works great in Travis. Here’s an
example .travis.yml file:
language: php
php:
- 7.2
before_script:
- composer install
script:
- ./vendor/bin/wpacceptance run
sudo: required
services: docker
Debugging
• WP Acceptance provides tools for debugging
problematic tests locally.
• Use verbose flag(s):

wpacceptance run -v
• Watch the browser as tests run:

wpacceptance run --show_browser
• Run the tests slower:

wpacceptance run --slowmo=500
Examples
• https://github.com/10up/distributor
• https://github.com/10up/safe-redirect-manager
• https://github.com/10up/10up-experience
Extensive Documentation
https://wpacceptance.readthedocs.io/en/latest/
Questions?
taylor.lovett@10up.com

@tlovett12

10up.com

More Related Content

What's hot

Testing nightwatch, by David Torroija
Testing nightwatch, by David TorroijaTesting nightwatch, by David Torroija
Testing nightwatch, by David TorroijaDavid Torroija
 
Getting up and running with selenium for automated Code palousa
Getting up and running with selenium for automated  Code palousaGetting up and running with selenium for automated  Code palousa
Getting up and running with selenium for automated Code palousaEmma Armstrong
 
Testing Code.org's Interactive CS Curriculum
Testing Code.org's Interactive CS CurriculumTesting Code.org's Interactive CS Curriculum
Testing Code.org's Interactive CS CurriculumBrian Jordan
 
How do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientHow do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientColdFusionConference
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Max Andersen
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web ApplicationsSeth McLaughlin
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberKMS Technology
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocketMing-Ying Wu
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
JavaLand - Integration Testing How-to
JavaLand - Integration Testing How-toJavaLand - Integration Testing How-to
JavaLand - Integration Testing How-toNicolas Fränkel
 
An Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorAn Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorCubet Techno Labs
 

What's hot (20)

Testing nightwatch, by David Torroija
Testing nightwatch, by David TorroijaTesting nightwatch, by David Torroija
Testing nightwatch, by David Torroija
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
Getting up and running with selenium for automated Code palousa
Getting up and running with selenium for automated  Code palousaGetting up and running with selenium for automated  Code palousa
Getting up and running with selenium for automated Code palousa
 
Apache Maven In 10 Slides
Apache Maven In 10 SlidesApache Maven In 10 Slides
Apache Maven In 10 Slides
 
Maven
MavenMaven
Maven
 
Testing Code.org's Interactive CS Curriculum
Testing Code.org's Interactive CS CurriculumTesting Code.org's Interactive CS Curriculum
Testing Code.org's Interactive CS Curriculum
 
How do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientHow do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and Client
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Locking Down CF Servers
Locking Down CF ServersLocking Down CF Servers
Locking Down CF Servers
 
Maven
MavenMaven
Maven
 
ASP.NET MVC Extensibility
ASP.NET MVC ExtensibilityASP.NET MVC Extensibility
ASP.NET MVC Extensibility
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
 
Testing Web Applications
Testing Web ApplicationsTesting Web Applications
Testing Web Applications
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using Cucumber
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
 
JavaLand - Integration Testing How-to
JavaLand - Integration Testing How-toJavaLand - Integration Testing How-to
JavaLand - Integration Testing How-to
 
An Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorAn Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using Protractor
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 

Similar to WordPress Acceptance Testing, Solved!

The WP Engine Developer Experience. Increased agility, improved efficiency.
The WP Engine Developer Experience. Increased agility, improved efficiency.The WP Engine Developer Experience. Increased agility, improved efficiency.
The WP Engine Developer Experience. Increased agility, improved efficiency.WP Engine
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudCarlos Sanchez
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Drupalcon Paris
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIWP Engine
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsTaylor Lovett
 
Rock Solid Deployment of Web Applications
Rock Solid Deployment of Web ApplicationsRock Solid Deployment of Web Applications
Rock Solid Deployment of Web ApplicationsPablo Godel
 
WordPress and The Command Line
WordPress and The Command LineWordPress and The Command Line
WordPress and The Command LineKelly Dwan
 
Anatomy of a Build Pipeline
Anatomy of a Build PipelineAnatomy of a Build Pipeline
Anatomy of a Build PipelineSamuel Brown
 
Hands On with Selenium and WebDriver
Hands On with Selenium and WebDriverHands On with Selenium and WebDriver
Hands On with Selenium and WebDriverTechWell
 
Azure DevOps Deployment Group
Azure DevOps Deployment GroupAzure DevOps Deployment Group
Azure DevOps Deployment GroupRiwut Libinuko
 
Structured Functional Automated Web Service Testing
Structured Functional Automated Web Service TestingStructured Functional Automated Web Service Testing
Structured Functional Automated Web Service Testingrdekleijn
 
Better Testing With PHP Unit
Better Testing With PHP UnitBetter Testing With PHP Unit
Better Testing With PHP Unitsitecrafting
 
Andreas Grabner - Performance as Code, Let's Make It a Standard
Andreas Grabner - Performance as Code, Let's Make It a StandardAndreas Grabner - Performance as Code, Let's Make It a Standard
Andreas Grabner - Performance as Code, Let's Make It a StandardNeotys_Partner
 
PWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service WorkerPWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service Workerjungkees
 
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsDevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsAmazon Web Services
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf
 

Similar to WordPress Acceptance Testing, Solved! (20)

The WP Engine Developer Experience. Increased agility, improved efficiency.
The WP Engine Developer Experience. Increased agility, improved efficiency.The WP Engine Developer Experience. Increased agility, improved efficiency.
The WP Engine Developer Experience. Increased agility, improved efficiency.
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
 
Best Practices for Building WordPress Applications
Best Practices for Building WordPress ApplicationsBest Practices for Building WordPress Applications
Best Practices for Building WordPress Applications
 
Rock Solid Deployment of Web Applications
Rock Solid Deployment of Web ApplicationsRock Solid Deployment of Web Applications
Rock Solid Deployment of Web Applications
 
WordPress and The Command Line
WordPress and The Command LineWordPress and The Command Line
WordPress and The Command Line
 
Anatomy of a Build Pipeline
Anatomy of a Build PipelineAnatomy of a Build Pipeline
Anatomy of a Build Pipeline
 
Hands On with Selenium and WebDriver
Hands On with Selenium and WebDriverHands On with Selenium and WebDriver
Hands On with Selenium and WebDriver
 
FV04_MostoviczT_RAD
FV04_MostoviczT_RADFV04_MostoviczT_RAD
FV04_MostoviczT_RAD
 
Pyramid deployment
Pyramid deploymentPyramid deployment
Pyramid deployment
 
Azure DevOps Deployment Group
Azure DevOps Deployment GroupAzure DevOps Deployment Group
Azure DevOps Deployment Group
 
Structured Functional Automated Web Service Testing
Structured Functional Automated Web Service TestingStructured Functional Automated Web Service Testing
Structured Functional Automated Web Service Testing
 
Better Testing With PHP Unit
Better Testing With PHP UnitBetter Testing With PHP Unit
Better Testing With PHP Unit
 
Andreas Grabner - Performance as Code, Let's Make It a Standard
Andreas Grabner - Performance as Code, Let's Make It a StandardAndreas Grabner - Performance as Code, Let's Make It a Standard
Andreas Grabner - Performance as Code, Let's Make It a Standard
 
Maven advanced
Maven advancedMaven advanced
Maven advanced
 
19servlets
19servlets19servlets
19servlets
 
PWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service WorkerPWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service Worker
 
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsDevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release Pipelines
 

More from Taylor Lovett

Transforming WordPress Search and Query Performance with Elasticsearch
Transforming WordPress Search and Query Performance with Elasticsearch Transforming WordPress Search and Query Performance with Elasticsearch
Transforming WordPress Search and Query Performance with Elasticsearch Taylor Lovett
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseTaylor Lovett
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterpriseTaylor Lovett
 
Wordpress search-elasticsearch
Wordpress search-elasticsearchWordpress search-elasticsearch
Wordpress search-elasticsearchTaylor Lovett
 
Modernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchModernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchTaylor Lovett
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPressTaylor Lovett
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPressTaylor Lovett
 
The JSON REST API for WordPress
The JSON REST API for WordPressThe JSON REST API for WordPress
The JSON REST API for WordPressTaylor Lovett
 
What You Missed in Computer Science
What You Missed in Computer ScienceWhat You Missed in Computer Science
What You Missed in Computer ScienceTaylor Lovett
 
Saving Time with WP-CLI
Saving Time with WP-CLISaving Time with WP-CLI
Saving Time with WP-CLITaylor Lovett
 

More from Taylor Lovett (10)

Transforming WordPress Search and Query Performance with Elasticsearch
Transforming WordPress Search and Query Performance with Elasticsearch Transforming WordPress Search and Query Performance with Elasticsearch
Transforming WordPress Search and Query Performance with Elasticsearch
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
 
Wordpress search-elasticsearch
Wordpress search-elasticsearchWordpress search-elasticsearch
Wordpress search-elasticsearch
 
Modernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with ElasticsearchModernizing WordPress Search with Elasticsearch
Modernizing WordPress Search with Elasticsearch
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
The JSON REST API for WordPress
The JSON REST API for WordPressThe JSON REST API for WordPress
The JSON REST API for WordPress
 
What You Missed in Computer Science
What You Missed in Computer ScienceWhat You Missed in Computer Science
What You Missed in Computer Science
 
Saving Time with WP-CLI
Saving Time with WP-CLISaving Time with WP-CLI
Saving Time with WP-CLI
 

Recently uploaded

Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyUXDXConf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...FIDO Alliance
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKUXDXConf
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfFIDO Alliance
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfFIDO Alliance
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Julian Hyde
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsStefano
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 

Recently uploaded (20)

Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 

WordPress Acceptance Testing, Solved!

  • 2. What Is the Purpose of Automated Testing? • Testing helps us reduce bugs/regressions and ensures our application meets requirements. • Manual testing, while also useful and important, is slow, expensive, and prone to human error. • Automated testing can be integrated such that it is run continuously e.g. part of a development and delivery pipeline.
  • 3. Types of Automated Testing • There are many different types of automated testing: unit, functional, performance, acceptance/end-to-end, integration, etc. • WordPress bundles integration/unit tests as well as end to end tests for certain features.
  • 4. Automated Testing Tools • WordPress PHPUnit Test Suite - the framework used by core and one you can include in plugins/themes to write integration tests. Based on PHPUnit. • WP Mock - a project started by 10up for writing true unit tests for WordPress. Also based on PHPUnit. • A number of acceptance testing frameworks e.g. Codeception. Custom built ones e.g. Gutenberg’s end-to-end testing system. • JS testing frameworks
  • 5. What Is Acceptance Testing? • Acceptance testing is testing that an application behaves as expected. • In the web application world, this usually means simulating a real user interacting with a web application via a browser.
  • 6.
  • 7. The Problem • Acceptance testing is challenging because everyone and every system (CI) running the tests must be running the tests against the same codebase, environment, and database.
  • 8. The Problem (cont.) • Codeception is a popular PHP framework for writing acceptance tests. The framework does not bundle any functionality around the environment or database sharing. • Different engineers on the team often run different local environments leading to test inconsistencies. • When an engineer runs the tests on their local, the tests are run against their local database. Different members of the engineering team have different local databases and it is tough to keep everyone in sync. • To make this work with CI you’d have to create a way for your CI tool to start a web environment and pass it predefined database exports. https://codeception.com
  • 9. WP Acceptance Overview • WP Acceptance is a toolkit that empowers developers and CI pipelines to test codebases using version controlled acceptance tests and sharable environments. https://github.com/10up/wpacceptance
  • 10. What Makes WP Acceptance Powerful? • WP Acceptance lets you create environment instructions to be version controlled with your tests. Every time you, a team member, or a CI pipeline run the tests, an environment will be created from those instructions guaranteeing the same results for everyone.
  • 11. Environment Instructions • Environment instructions look like this:
 install wordpress where version is latest and url is http://url.test
 
 activate plugin where name is safe-redirect-manager
 install theme where name is twentynineteen
 
 create post where title is Test and content is “Test content” Read about supported instructions: https://github.com/10up/wpinstructions
  • 12. wpacceptance.json • All WP Acceptance projects contain a file named wpacceptance.json. Here’s an example: { "name": "10up-experience", "exclude": [ "node_modules" ], "tests": [ "./tests/wpa/*.php" ], "enforce_clean_db": false, "project_path": "%WP_ROOT%/wp-content/plugins/10up-experience", [ "install wordpress where url is http://10upexperience.test", "activate plugin where name is 10up-experience", "install theme where name is twentynineteen" ] ] }
  • 13. Snapshots • Sometimes you need to test in a complex environment e.g. you are building a site with 30 plugins and large database for a client. • For this, you will want to use a Snapshot. WP Acceptance lets you run your tests on Environment Instructions or Snapshot(s). • Snapshots are based on the WP Snapshots project: https://github.com/10up/wpsnapshots
  • 14. Snapshots (cont.) • In the snapshot workflow you will need to prepare a “primary” snapshot for the development team to use. • You can run WPA against your local environment and save the snapshot:
 wpacceptance run --local --save_snapshot • This will update your wpacceptance.json file with the new snapshot ID so other developers/CI can use that snapshot. • When major changes are made to the site e.g. new content types, you will want to create a new snapshot.
  • 15. wpacceptance.json • Here’s a wpacceptance.json file using WP Snapshots: { “name": "distributor", "exclude": [ "./node_modules" ], "tests": [ "tests/wpacceptance/*Test.php" ], "snapshots": [ { "snapshot_name": "WordPress 5.1.1", "snapshot_id": "fec81ac24227af6554c93d28d9af2bdf" } ], "enforce_clean_db": true, "bootstrap": "tests/wpacceptance/bootstrap.php", "repository": "10up" }
  • 16. Install and Usage • WP Acceptance is added to a project via Composer. You can use it on a theme, plugin, or in any WordPress application. • Step 1: composer require 10up/wpacceptance • Step 2: Create your wpacceptance.json file (or run ./vendor/bin/wpacceptance init) • Step 3: ./vendor/bin/wpacceptance run
  • 17. A Simple Test You can see a test lets us interact with the website as a user. If “Modal Title” is not visible after clicking .modal-link, the test will fail. $I = $this->openBrowserPage();
 $I->moveTo( '/' );
 $I->click( 'a.modal-link' );
 $I->seeText( 'Modal Title' );
  • 18. Testing the Admin $I = $this->openBrowserPage();
 $I->login();
 $I->moveTo( '/wp-admin/profile.php' );
 $I->waitUntilElementVisible( '#wpadminbar' );
 $I->fillField( '#first_name', 'Test Name' );
 $I->click( '#submit' );
 $I->waitUntilElementVisible( '#wpadminbar' );
 $I->seeValueInAttribute( '#first_name', 'value', 'Test Name', 'Profile field did not update.' );
  • 19. Saving a Post $I = $this->openBrowserPage(); $I->loginAs( 'admin' ); $I->moveTo( 'wp-admin/post-new.php?post_type=redirect_rule' ); $I->fillField( '#srm_redirect_rule_from', '/test' ); $I->fillField( '#srm_redirect_rule_to', '/test2' ); $I->fillField( '#srm_redirect_rule_notes', 'Notes' ); $I->click( '#publish' ); $I->waitUntilElementVisible( '.updated' ); $I->seeValueInProperty( '#srm_redirect_rule_from', 'value', '/test' ); $I->seeValueInProperty( '#srm_redirect_rule_to', 'value', '/test2' ); $I->seeValueInProperty( '#srm_redirect_rule_notes', 'value', 'Notes' ); (From Safe Redirect Manager)
  • 20. Standard Test Suite • WP Acceptance includes standard tests that you can include in any test suite • The standard tests ensure basic functionality is working. This is useful as often times while building plugins and themes we can break things and not know about it.
  • 21. Standard Test Suite • Test the front end loads properly. • Test that an admin can create a post. • Test the admin bar is showing. • Test users can update their profile. • Test users can update general settings. • Etc.
  • 22. Standard Test Suite class MyTests extends WPAcceptancePHPUnitTestCase { /** * @testdox I can log in. */ public function testLogin() { parent::_testLogin(); } }
  • 23. Continuous Integration • WP Acceptance works great in Travis. Here’s an example .travis.yml file: language: php php: - 7.2 before_script: - composer install script: - ./vendor/bin/wpacceptance run sudo: required services: docker
  • 24. Debugging • WP Acceptance provides tools for debugging problematic tests locally. • Use verbose flag(s):
 wpacceptance run -v • Watch the browser as tests run:
 wpacceptance run --show_browser • Run the tests slower:
 wpacceptance run --slowmo=500