What is SimpleTest?• PHP Test Framework• A way to create and run automated regression tests• A functional testing environment: A pseudo-user navigates in a pseudo-browser and checks the results.• Manipulation (create user, drupalGet(), drupalPost())• Assertions (assertText(), assertPattern(), etc.)• A unit test class is also available, but the general emphasis is on functional testing.
Why Automated Testing?• Define exactly what the code should do • Easy development • Easy to refactor code • Less debugging • Less mistakes• Document Bugs • Prevent regressions • Quality Assurance • Better Software
Why Automated Testing?• Once a test is written, it will likely be run many many times• Every time it is run, it verifies that the code is still working• If it catches even one bug, it has “paid for itself” – high value• Can be used to help reproduce problems
How To Install?• In Drupal 7, Simpletest is preinstalled.• In Drupal 6, it must be installed as a contrib module and a patch must be applied to core - see the INSTALL.txt.• Enable simpletest module on the modules page (or "drush en simpletest")• Configure "verbose" mode at admin/build/testing/settings (on by default in D7)• Check the status page for problems (admin/reports/status)
so… how does it works?• .test files • Contain test classes • Test classes extend the SimpleTest class • DrupalUnitTestCase • DrupalWebTestCase • Use Helper methods to: • Simulate user actions • Check behavior