Drupal 6: Using Drupal SimpleTest To Test Nodes With CCK Values
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. In order to test that a CCK field saves the data for a test you need to do the following in the setUp() method, remember that this all happens before any tests are run.