DrupalUnitTestCase was reintroduced by #464714: Speed up the tests. From the doxygen:
/**
* Test case for Drupal unit tests.
*
* These tests can not access the database nor files. Calling any Drupal
* function that needs the database will throw exceptions. These include
* watchdog(), drupal_function_exists(), module_implements(),
* module_invoke_all() etc.
*/
However, it is much quicker than DWTC for what it can do. "chx: If i clock my CPU enough to time this i get 4s vs 0s..."
The page needs:
- at the end of the 1st sentence ", although unit testing is supported."
- at the end of the section "Separate testing environment" the following new paragraph—
"The database tables and files directory are not created for unit tests. This makes them much faster to initialise than functional tests but means that they cannot access the database or the files directory. Calling any Drupal function that needs the database will throw exceptions."
The comment, changing the testing url, needs to be rolled in and deleted too.
Marking critical b/c testing is so important to the dev process, especially nowish. We want people to be implementing this stuff when upgrading their modules. I have added a section on unit testing to the Simpletest tutorial, which I could edit: http://drupal.org/node/395012
Comments
Comment #1
arianek commentedadding tags
Comment #2
Rok Žlender commentedAs I don't have access to edit the http://drupal.org/simpletest-tutorial-drupal7 directly pasting unit test instructions here.
Comment #3
Rok Žlender commentedRevised. Also created an issue to add code to example module #1261014: Add unit test example to simpletest example module.
Comment #4
Rok Žlender commentedI should read through all the docs first http://drupal.org/node/811254 holds unit test docs. IMO we should move it to the same level as SimpleTest Tutorial (Drupal 7) and merge the example into example module.
Comment #5
arianek commentedYou're a star! Do you need a technical review? I can always tweet a link out and see if anyone will look at it, otherwise issues tend to stagnate...
Comment #6
Rok Žlender commentedI will review the existing unit test docs and provide example code for it in example module docs above will not be used.
Comment #7
willmoy commentedBrill! Lovely to see action on this. Am heading away for three weeks but if still needs sorting will pick this up then.
On a quick read this all looks good technically, needs some light grammar editing e.g.
"As unit testing does not use database we need to manually include any required files." < missing 'the' before database
But example.module seems like a good fit, with handbook page updated accordingly.
Thanks very much, Rok.
Comment #8
Rok Žlender commentedDocs are updated at http://drupal.org/node/811254 example module code got committed in #1261014: Add unit test example to simpletest example module I think this one is done.