Today we kick off a new series on writing tests for Drupal 7 using the SimpleTest framework included with Drupal core.
Testing is one of those things that we all wish we did more often. It helps reduce the number of bugs in our code, prevents regressions in functionality, and dramatically reduces the amount of time that we spend manually clicking through all the features of our applications ensuring they still work. Well now you can get started writing tests for your Drupal 7 powered applications, and increase the amount of time you get to spend working on fun new features, by writing tests that reduce the effort required to maintain your application's stability.
Drupal 7 was the first version of Drupal to include a testing framework in core, to encourage both core contributors and module developers to write tests that ensure the caliber of their code. Throughout this series we'll be taking a look at how we can use this testing framework—known as SimpleTest—in order to write test cases for the various capabilities of our own Drupal site. We'll learn about how SimpleTest provides tools for simulating human interaction with a website through a browser, allowing us as developers to essentially record a set of steps in code and then play them back over, and over, and over, verifying that the results are the same each time.
The concept of testing isn't specific to Drupal, nor is SimpleTest per se, but the Drupal version does provide some handy utilities for making it easier to write tests for a Drupal-based application. Throughout this series we'll also take a look at those tools and see how they can help to reduce the amount of code needed for our tests, which makes them quicker and easier to write. See, I told you, testing is all about reducing the time spent doing tedious, automatable, tasks.
This week, we start with the first 4 tutorials in this series. These tutorials provide an in-depth look at why automated testing is important and the basics of the SimpleTest framework that we'll be exploring.
- Introduction to Automated Testing with SimpleTest (FREE)
- What is Automated Testing?
- Understanding SimpleTest's Terminology and Methodology
- Installing SimpleTest and Running Tests
After completing this week's tutorials, you'll better understand the concept of automated testing and why it's an important part of any developer's toolkit. You'll also be able to define common terminology used in testing, as well as terminology specific to the SimpleTest framework. Finally, you'll be able to use Drush and the Drupal UI to run various tests that are included with core, and you'll see the output of these tests.
Next week, we dive into writing a basic hello world test, and we use the SimpleTest browser to navigate an application and submit forms.
Add new comment