Question

I'm a Java/Scala web-app developper, but I might have to dive head-first into WordPress. I am now preparing in anticipation of that. I am mostly looking for best practices.

The workflow should answer following (broad) questions:

  • How to run tests against the whole WordPress platform (to check if I didn't break anything), and how to run tests for the modules/features I am developing (how to do TDD)?

  • How should changes be forwarded from Dev to Production environment in a non-destructive manner? Provided Git is used for version control.

I understand that these questions are quite broad, but this tech stack (PHP, WordPress) is quite new to me.

No correct solution

OTHER TIPS

WordPress core has a set of phpunit tests. You can find documentation on running those tests at http://make.wordpress.org/core/handbook/automated-testing/ . Not many themes or plugins have test suites available, so you'll either have to write your own (and contribute them back to the community!) or build Selenium tests to verify the end result is ok.

For testing your own code, WP Mock might be the best solution.

There have been some developments since this question was asked! There are now mature BDD / TDD tools for WordPress. WP-Codeception is the tool of choice, since it incorporates Behat, PHPunit, WP-CLI and others. Codeception can run Gherkin files, just like Cucumber.

The WordPress modules for Codeception allow you to do WordPress "unit" tests in a variety of ways. You can snapshot the database, you can mock WordPress core functions, and you can do Selenium tests in the browser. You can get started here:

WordPress-BDD.com

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top