SimpleTest

Articles about using the Drupal SimpleTest module to unit test Drupal.

Mimicking Data Provider Functionality In Drupal SimpleTest

Tuesday, July 10, 2012 - 18:01

Although Drupal SimpleTest is an extremeley useful module it doesn't currently support data providers, which is a shame as I use that feature quite a bit in other testing frameworks. A data provider is a mechanism that allows you to call a single test case multiple times with different arguments so that you can ensure the correct output each time.

Category: 

Testing Multi Step Forms In Drupal 7

Thursday, June 14, 2012 - 10:12

I am currently using SimpleTest to test a complex multi-step form implementation in Drupal 7. It made sense to do it this way as there are a lot of factors involved that all need to be accounted for and automating what form elements appeared on what page was the most robust solution. In order to test how the form worked I needed to submit to the form once (using a $this->drupalPost() method) and then submit the form again using the same method. The tricky bit here was that when calling the drupalPost() method with a URL it first called drupalGet() on the URL before posting to the form.

Category: 

Logging In As Superuser In Drupal 6 SimpleTest

Thursday, May 19, 2011 - 12:08

Sometimes the most complex part of using SimpleTest is making sure that everything is working as it should before you start your tests. This means setting up the correct modules and creating the correct content types in advance. Because SimpleTest works by issuing CURL requests to pages the most reliable way of doing certain tasks is to use the administration forms as you normally would. Taking an example, if you want to enable a block from a module you should submit the block form, adding the blocks you need to the various different regions this like.

Category: 

Using Drupal SimpleTest To Test Nodes With CCK Values

Monday, December 13, 2010 - 22:03

SimpleTest is a great way to test your modules, but it can take a bit of setting up. For every test that is run SimpleTest effectively has a fresh install of Drupal, so if you need to test a particular function you need to have everything in place before you run the test. I was recently testing a migration module that I had written and needed to create nodes with a variety of CCK fields, which is quite common in Drupal site setups.

Category: 

Getting Started With Drupal 6 SimpleTest

Sunday, December 5, 2010 - 13:01

Drupal SimpleTest is a module that will allow you to unit test your own modules or unit test any patches you have made for third party modules. This module will be integrated into Drupal 7, but for Drupal 6 you have to do a couple of thngs before you can start testing. This article is a very quick introduction to Drupal SimpleTest and will be followed up by more articles in the future.

Category: 

Two Beginner Errors In Drupal 6 Simpletest

Thursday, October 7, 2010 - 18:29

Simpletest is a Drupal module that I have been using for about a week to unit test a module I have been working on. It is a brilliant and powerful module that every module developer should be using to test their code properly. I did, however, encounter a couple of wierd errors that took me a while to fix. So for the benefit of everyone else I thought I would post them here, along with the solutions. These errors are probably things that developers new to Drupal Simpletest will come across, which is why I have labelled them beginner errors.

Category: