Super high value Continuous Integration test with Drupal, Jenkins and Selenium

Sometimes unit testing is a lot of work, especially if you have a system that has had many months of development without it.

One very valuable test is to check there are no errors in the Drupal log after you've committed new code.

First I clear the Drupal error log when Jenkins runs an update from version control using Drush:

cd /var/lib/jenkins/jobs/mysite
drush --uri=http://test.mysite.com watchdog delete all

Then when I run the Selenium tests I load all the major pages of the site and do some other clicking around. Finally I visit the dblog report and check there are no errors (The source code of the table below can be put directly into your Selenium test script, just omit the <table> tags, but this assumes you're using html based test suites):

The Selenium Steps

open /admin/reports/dblog
click link=Filter log messages
addSelection id=edit-severity label=emergency
addSelection id=edit-severity label=alert
addSelection id=edit-severity label=critical
addSelection id=edit-severity label=error
addSelection id=edit-severity label=warning
addSelection id=edit-severity label=debug
clickAndWait id=edit-submit
assertTextPresent No log messages available.

The Selenium Code

<tr>
  <td>open</td>
  <td>/admin/reports/dblog</td>
  <td></td>
</tr>
<tr>
<td>click</td>
<td>link=Filter log messages</td>
<td></td>
</tr>
<tr>
<td>addSelection</td>
<td>id=edit-severity</td>
<td>label=emergency</td>
</tr>
<tr>
<td>addSelection</td>
<td>id=edit-severity</td>
<td>label=alert</td>
</tr>
<tr>
<td>addSelection</td>
<td>id=edit-severity</td>
<td>label=critical</td>
</tr>
<tr>
<td>addSelection</td>
<td>id=edit-severity</td>
<td>label=error</td>
</tr>
<tr>
<td>addSelection</td>
<td>id=edit-severity</td>
<td>label=warning</td>
</tr>
<tr>
<td>addSelection</td>
<td>id=edit-severity</td>
<td>label=debug</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=edit-submit</td>
<td></td>
</tr>
<tr>
  <td>assertTextPresent</td>
  <td>No log messages available.</td>
  <td></td>
</tr>

Post new comment

By submitting this form, you accept the Mollom privacy policy.

User login

Author of...

  • @Casablanca Looks like a great time last night. Sorry I couldn't make it :( 13 years 26 weeks ago
  • Our new homepage is live http://t.co/iwNX1tWZ 13 years 26 weeks ago
  • Can you help with conditionally setting the 'from' in mails sent with notifications/messaging modules #drupal http://t.co/ItE75IlW 13 years 26 weeks ago
  • My post about highjacking #Drupal menu items with 'drupal_get_form' callbacks for creating popups or #ahah goodness http://t.co/Pe9wSz6k 13 years 27 weeks ago
  • Oh the conflict within. An entire section of a #drupal site was built bespoke, do I add a bespoke subsection, or rewrite the entire section? 13 years 30 weeks ago
  • @psd It depends. Serving static pages means https has a larger relative impact. If there's a lot of processing, https is relatively small. 13 years 31 weeks ago
  • Just had a play with the #drupal Field collection module. goo.gl/p6sEn A really nice Drupal 7 implementation of the multigroup module. 13 years 31 weeks ago
  • @philhawksworth @a_alfredo When will scampcat have the descriptions pop up when you hover over the markers? 13 years 31 weeks ago
Oliver Polden