2. Who Am I?
Simon Roberts
IT Consultant,
Taniwha Solutions
Using PHP since ~1996
Using Drupal since 2005
http://drupal.org/user/33667
First used SimpleTest at Drupalcon Szeged
Testing Sprint
3. Who Am I?
Before the Drupalcon, I’d only had the
most casual of looks at Testing in Drupal
Have used JUnit etc previously
Was able to provide useful tests to
Drupal Core inside a couple of hours!!
You can too!
4. What was SimpleTest?
PHP Testing Framework
Integrated as a contributed module in
D5 + D6
Integrated in core for Drupal 7 (sortof)
Implements Automated Testing
5. Why Automated Testing?
Define exactly what the code should do
Easier development
Easier to refactor code
Less debugging
Less mistakes
More fun!!
8. 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
9. Testing in Drupal Core
Dries (and Drupal!) has made Testing a high priority
for Drupal 7
http://buytaert.net/drupal-7-timeline
The actual Drupal 6 Timeline
Effective Test coverage allows us to compress the “fix”
phase of a Drupal release (code freeze)
The Drupal 7 timeline assuming that we fully embrace testing.
Note: These dates are going to be delayed anyway - slower migration to Drupal 6
than expected (eg: CCK, Views, Panels. drupal.org)
11. so... how does it work?
.test files
Contain test classes
Test classes extend the SimpleTest class
well, not exactly
Use Helper methods to:
Simulate user actions
Check behavior
13. What’s Left To Do?
Outstanding Testing Issues
http://drupal.org/project/issues?
projects=3060&versions=156281&components=simpletest.module,tests
“We currently have 38 tests taken out of
43 for a test coverage of 88%. This will
change when the misnamed tests are
merged.” http://groups.drupal.org/node/9408
14. References
Webchick’s presentation “Testing Part 1: Intro to
Testing” (Szeged Drupalcon)
http://drupal.org/simpletest
http://groups.drupal.org/testing-qa
One SimpleTest template to rule them all
http://groups.drupal.org/node/7731
Drupal testing patterns
http://groups.drupal.org/node/15190