+ All Categories
Home > Technology > Testing In Drupal

Testing In Drupal

Date post: 28-Jan-2015
Category:
Upload: ryan-cross
View: 110 times
Download: 0 times
Share this document with a friend
Description:
Simple Test
Popular Tags:
14
Testing in Drupal An Introduction
Transcript
Page 1: Testing In Drupal

Testing in DrupalAn Introduction

Page 2: Testing In Drupal

Who Am I?

Simon RobertsIT Consultant,Taniwha SolutionsUsing PHP since ~1996Using Drupal since 2005http://drupal.org/user/33667

First used SimpleTest at Drupalcon Szeged Testing Sprint

Page 3: Testing In Drupal

Who Am I?

Before the Drupalcon, I’d only had the most casual of looks at Testing in DrupalHave used JUnit etc previouslyWas able to provide useful tests to Drupal Core inside a couple of hours!!You can too!

Page 4: Testing In Drupal

What was SimpleTest?

PHP Testing FrameworkIntegrated as a contributed module in D5 + D6Integrated in core for Drupal 7 (sortof)Implements Automated Testing

Page 5: Testing In Drupal

Why Automated Testing?

Define exactly what the code should do Easier development Easier to refactor code Less debugging Less mistakes More fun!!

Page 6: Testing In Drupal

Why Automated Testing?

Document Bugs$xss = '<script>alert("xss")</script>'; $edit = array(

'title' => $xss,

);

$node = $this->drupalCreateNode($edit);

$this->drupalGet('node/' . $node->nid . '/edit');

$this->assertNoRaw($xss, t('Harmful tags are escaped.'));

Page 7: Testing In Drupal

Why Automated Testing?

Document BugsPrevent regressionsQuality AssuranceBetter Software

Safety net!

Page 8: Testing In Drupal

Why Automated Testing?

Once a test is written, it will likely be run many many timesEvery time it is run, it verifies that the code is still workingIf it catches even one bug, it has “paid for itself” - High valueCan be used to help reproduce problems

Page 9: Testing In Drupal

Testing in Drupal Core

Dries (and Drupal!) has made Testing a high priority for Drupal 7http://buytaert.net/drupal-7-timeline

Effective Test coverage allows us to compress the “fix” phase of a Drupal release (code freeze)

The actual Drupal 6 Timeline

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)

Page 10: Testing In Drupal

Not just for Drupal Core!

Page 11: Testing In Drupal

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

Page 12: Testing In Drupal

No, really... how does it work?

Let me show you...

Page 13: Testing In Drupal

What’s Left To Do?

Outstanding Testing Issueshttp://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

Page 14: Testing In Drupal

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 allhttp://groups.drupal.org/node/7731

Drupal testing patternshttp://groups.drupal.org/node/15190


Recommended