Community Documentation

Troubleshooting tests

Last updated December 23, 2011. Created by boombatower on March 8, 2009.
Edited by ekes, jhodgdon, gollyg, matt2000. Log in to edit this page.

Use the new debug()

If you are using the latest version of simpletest in Drupal 7 you can use the debug feature. The debug feature and the verbose mode are explained here.

Print out Random Variables

Often you want to print out variables to see what they contain. In simpletest this is not particularly possible, but you can output them to the results screen inside of the message associated with a test that has passed:

<?php
$var
= $this->doAwesomeStuff($settings);
$this->pass(var_export($var, TRUE));
?>

View the content of the Current Page

Many tests will get a page, or post to a page. By enabling 'Verbose mode' in Simpletest's settings, you can view each page via links in the test results. Be warned that this is not a perfect representation of the page as it would be seen by a human user.

For example, uploaded images are rendered as usual, but will not be visible in this viewer. (Typically because the test files no longer exist by the time you're reviewing this HTML. They were removed during Simpletest's clean-up process.)

You can also use this code to write the page to a file:

<?php
file_put_contents
('output.html', $this->drupalGetContent());
?>

0 bytes from a GET

It's possible to get messages like:

GET http://example.local/member returned 0 (0 bytes).

as a failure. This is usually an indication of a "white screen of death" in your site, but can also be caused by a DNS lookup failure, or other failure to make a HTTP request to the site. Make sure that the server does not fail the HTTP status test, if it is failing follow the instructions to, for example: add a DNS entry for the site that is the same as where you are accessing it, change firewall or SE Linux settings.

xdebug

The Simpletest reference Tips page has a section at the bottom on getting xdebug working with Simpletest.