1 min read

Categories

Tags

Continuous Integration (CI) at a high level is testing every code push from each developer, every time. While this sounds like an argues task, it does not have to be. Drupal and Wordpress both have tools available that can help you test your code.

PHP CodeSniffer

PHP CodeSniffer is a command line (cli) utility that will check your php, JavaScript, and CSS to verify it meets a set of coding standards. Xeno Media has a nice walkthrough, WordPress coding standards for the Drupal developer that will help you get setup for local testing. The steps are similar if you are testing on a server via bash scripts or using Jenkins. Using and testing for coding standards help when onboarding new developers or reviewing code you wrote months ago.

Behat

Behat is a Behavior-Driven Development testing tool. Wordhat and Drupal Behat Extension provide most of what you need for testing your sites.

With Behat you can “walk” through your site one scenario at a time. You can fill out forms as a user would. Check for the existence of text on a page, even limit it to a pre-defined region of your site like the #footer. You can also log in a user with a specific role to test the admin or user function.

PHPUnit

Of the three I am covering here, PHPUnit is the most involved. Each module or plugin you write needs a compatible test written. In this case, each class is proven to work with the test data provided. From the results, you can be ensured the new code has not broken the site. IMO the best way to work with PHPUnit is to use Test Driven Development (TDD); where you start with a failing test and write the code needed to get it to pass.

Summary

These three methods are only some of the tests you can run on your site but they cover the bulk of changes made by the development team. Testing your code as you go ensures a better product and allows you to act quickly if an issue arises; most times before it goes live.