Introducing WP Acceptance

Sample of successful execution of WP Acceptance.

WP Acceptance—a team-centric tool we’ve built for writing reliable, scalable acceptance tests—is now available in beta. Part of our pursuit of finely crafted web experiences, we think that WP Acceptance will help ensure stable releases and fewer regressions for WordPress applications. This toolkit lets developers and continuous integration (CI) pipelines test codebases through version-controlled acceptance tests and sharable, defined file and database snapshots.

We’re considering this a public beta release. It won’t adversely affect your application or introduce instability, but it has not yet been thoroughly tested as a framework and may have some bugs. Through our own testing and community involvement, we’ll further solidify WP Acceptance as it approaches a full, public release.

What Is an Acceptance Test?

Acceptance tests ensure that an application behaves as expected. This usually means simulating a real user interaction with a web application in a browser. This type of testing, when done well, helps to yield much more stable applications, especially by focusing on how the user will experience the application.

Why Another Acceptance Testing Framework?

There are a few flaws with the existing acceptance testing frameworks that inspired us to make WP Acceptance. Most significantly, to run the tests locally, every developer must be using the same database and permalink structure to get the same results. This can present issues when one team member makes a change and the database gets out of sync. Another problem is that these solutions can’t be tested at the time engineers submit code (within a CI pipeline) without first merging the untested changes into a production or staging environment. WP Acceptance solves these problems.

WP Acceptance runs tests against either a local environment (preferably WP Local Docker) or a WP Snapshot stored in the cloud. Once a working WP Snapshots ID is committed to the project, anyone on the team can run tests against the same database and permalink structure stored in the Snapshot. We have in-depth documentation explaining how and why WP Snapshots integrates with WP Acceptance. Since WP Acceptance tests exist in Git and integrate with Travis CI or GitLab CI/CD, you don’t have to worry about merging code into production or staging before running the tests.

How Does It Work?

WP Acceptance allows you to write acceptance tests in PHP. Tests look like this:

$I = $this->getAnonymousUser();
$I->moveTo( '/' );
$I->click( 'a.modal-link' );
$I->seeText( 'Modal Title' );

Each test simulates interactions with the website as if a person was visiting the site. In the example test above, if the text “Modal Title” is not visible after clicking a link with the class “.modal-link,” this example test will fail. Each project can have a suite of tests, similar to unit testing. Each project will have a wpacceptance.json file that defines settings including where the tests are located.

WP Acceptance is executed from the command line and can be installed via Composer. Details can be found in the installation instructions. It can also be included in Travis CI (or GitLab CI/CD) so that other developers can be notified when tests fail. WP Acceptance has an extensive documentation site with examples to help you get set up and running with reliable and scaled acceptance tests.

Integrated with Distributor

We are already using WP Acceptance for Distributor to help ensure stability and mitigate regressions across releases. We’ve written an extensive test library that runs through everything from distributing posts to creating connections to ensuring content updates sync properly. Each test integrates directly with Travis CI such that every pull request is run against our WP Acceptance test suite. The test suite is already helping us prevent regressions as we develop new features.

What’s on the Roadmap?

We’re continuing to refine the plugin as we apply it to more real-world projects and test cases, and want to encourage community collaboration as we steam ahead toward our “1.0.0” release. We relish the open-source process and look forward to receiving feedback and code contributions as we seek to make WP Acceptance a vital tool for development teams. Our current focus is ensuring overall stability and speeding up test execution.

Start using WP Acceptance by visiting the project page on Github.

  1. Just what I have been looking for the Matador Jobs plugin

    Thanks Guys

    • Paul – glad to see you’ve found a good use for WP Acceptance. Any initial feedback on things that could make it more useful for you?

  2. Concise and effective. I look forward to giving this a try!

Leave a Reply to Paul Bearne

Cancel Reply

Finely crafted websites & tools that make the web better.