Trouble shooting simpletest
Trouble shooting simpletests.
Use the new debug()
If you are using the latest version of simpletest in Drupal 7 you can leverage a new debug feature. It, and the new 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));
?>Print out the Content of the Current Page
Many tests will get a page, or post to a page. If you want to inspect the content of the resulting page you can use this code:
<?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. Make sure that the server where simpletest is running has a DNS entry for the site that is the same as where you are accessing it.
