I have been using Drupal for nearly 4 weeks now, and SimpleTest even less. I just wanted to share some things which I found, and that others learning SimpleTest should look out for.
The first snag I ran into whilst diving into SimpleTest (always did push buttons first, read instructions later) was when I tried to run sequential tests.
public function testAddBroadcast(){} public function testAddNodeToBroadcast(){}
When I tried to add the node to the broadcast I had created in the first function, I found that it didn't exist. This is because SImpleTest will call the setUp and tearDown methods on each one of the tests, like so:
It's such a simple thing to overlook, but affected the performance of my tests dramatically.
Another one that had me stumped for a while was calling $this->fail() from within the setUp() method. I'm not sure about other browsers, but in Chrome (v5.0.375.70 Ubuntu 10.04 x64), calling this would actually result in the page crashing.
It seems that if you want to use this method, or any others for that matter (pass, fail, assertText, etc), you're going to have to set them to a class member, and check that value in each test.
drupalPost(), as wonderful as it is, requires the URL to point to the page in which the form is located, rather than the action page, because it will fetch the form page and check that the input fields exist before populating them and submitting them, rather just just simply send a POST request with the passed parameters.
This becomes a problem when the page in question is almost entirely driven by Javascript, which sends fields that are not necessarily hard-coded into the HTML, causing drupalPost() to fail when it can't find the input elements with those names.
I don't care what it says in the documentation, unless I somehow got a dodgy download, $this->assertLinkByHref() isn't a native method; how about writing your own? This is my brief (and limited) implementation.