Disclaimer: I’ve had several people contacting me that they didn’t get this thing to work. I guess i still left out some crucial installation/configuration parts. Use with care!
This step by step tutorial explains HOWTO run functional tests in Drupal core. We will do this both from within drupal and from within eclipse.
My machine is running Ubuntu 7.10 and uses the standard Lamp stack which comes with it. PHP 5, Mysql 5, Apache2.
I’m supposing that you already know howto install eclipse 3.3 PDT because the following steps are based on that. _Basically: Just download the all_in_one PDT package, and unpack it into some ~/software/ folder_
1. Get the files
We will use eclipse to checkout drupal core from CVS.
You can also watch this screencast to see how it’s done. [Poor sound quality, sorry for that]
- Switch to the CVS perspective by choosing
- Windows>Open Perspective>Other
- Windows>Open Perspective>Other
- Select “CVS repository perspective”
- Add a new CVS repository location for drupal core
- Right click in the view on your left, and select New > Repository location
- Use the following settings and press “Finish”
- Host : cvs.drupal.org
- R. Path : /cvs/drupal
- User : anonymous
- Passwd : anonymous
- Host : cvs.drupal.org
- Conn. Type : pserver
- Check-out Drupal HEAD version
- Expand :pserver:anonymous@cvs.drupal.org:/cvs/drupal
- Expand HEAD
- Right click on drupal
- Checkout as project
- select “Check out as project in the workspace”
- call it drupaltesting
- select “Check out as project in the workspace”
- Finish
- Expand :pserver:anonymous@cvs.drupal.org:/cvs/drupal
- it will be saved into a folder <workspace-location>/drupaltesting
2. prepare your server
- CURL is needed for the doing the actual requests on the drupal webpages
- install curl
- sudo apt-get install curl
- install curl extension for php
- install curl
- sudo apt-get install php5-curl
- serve from http://drupaltesting
- in a later stage we are expecting that drupal is not hosted in a subdirectoy of some webroot
- link to drupal in /var/www
- sudo ln -s <workspace-location>/drupaltesting /var/www/drupaltesting
- edit VHOSTs
- sudo gedit /etc/apache2/sites-enabled/000-default
- in a later stage we are expecting that drupal is not hosted in a subdirectoy of some webroot
- append the following code at the end of the file
<VirtualHost *>
ServerName drupaltesting
DocumentRoot /var/www/drupaltesting
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/drupaltesting>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
- 127.0.0.1 localhost
- by
- 127.0.0.1 localhost drupaltesting
- restart apache
- sudo /etc/init.d/apache2 restart
- 3. install drupal from http://drupaltesting as you would normally do
3. Run tests from within drupal

• enable the simpletest module in http://drupaltesting/admin/build/modules
• To get an overview of all the tests available
- go to http://drupaltesting/admin/build/simpletest
- Select the aggregator test and press ‘Run selected tests’
- this can take a while so don’t try to run ALL TEST at this moment because you will be waiting for at least 15 minutes.
- Hopefully you’ll be presented a list of a few hundred tests which are all green
4. Run tests from within eclipse
I’m not 100% sure if all following steps are necessary but i had already spend considerable time getting the stuff working, so i preferred writing this doc iso refining the steps.
- Install php commandline
- sudo apt-get install php5-cli
- Install the plugin
- Download version 0.2.3 from Sourceforge
- Unpack that zip, which contains a local update site containing only version 0.2.3
- Install it by adding a new local update site which points to the location where you just unpacked the zip.
- The update site http://simpletest.org/eclipse/ only provides version 0.2.1. Don’t use that version as it is outdated.
- Configure the plugin
- Windows>preferences>simpletest
- php.exe file : /usr/bin/php
- php.ini file : /ets/php5/conf.d/mysql.ini
- simpletest path : /var/www/drupaltesting/modules/simpletest/simpletest
- Include path : /var/www/drupaltesting/test/test.inc
- php.exe file : /usr/bin/php
- Suffix : *.test
- Configure the default php server
- Windows > Preferences > PHP > PHP Server > New
- Name : drupaltesting
- Name : drupaltesting
- URL : http://drupaltesting
- Windows > Preferences > PHP > PHP Server > New
- Press Finish
- Select that server and make it “Default”
- Hacking the plugin
- Our simpletests NEED drupal, that is why Douglas gave me small php script to include in the tests to be able to run them correctly from within the plugin. Download that file here and save it as /var/www/drupaltesting/test/test.inc.
- By default the plugin can only be activated when right-clicking on *.php files, we would like it to also work from drupal’s *.test files.
- To solve that you need to download the adapted plugin.xml into your eclipse/plugins/net.sf.simpletest.eclipse_0.2.3/ folder, and thus overwriting the plugin.xml which is there.
- Or you edit that plugin.xml yourself and search for extension=“php” attributes and replace them by extension=“test”. Also search for <test property=“org.eclipse.debug.ui.matchesPattern” value=”*.php”/> and replace that by <test property=“org.eclipse.debug.ui.matchesPattern” value=”*.test”/>
- Restart eclipse
- Right click on /drupaltesting/modules/aggregator/aggregator.test
- To solve that you need to download the adapted plugin.xml into your eclipse/plugins/net.sf.simpletest.eclipse_0.2.3/ folder, and thus overwriting the plugin.xml which is there.
- In the context menu Your should see Run As > Simpletest
- I have noticed that this hacking only works properly if you move that net.sf.. folder first to another location, start eclipse without that plugin, close eclipse, make the changes in the plugin.xml and place the folder back in it’s original location, restart eclipse.
| Attachment | Size |
|---|---|
| test.inc.txt | 596 bytes |
| plugin.xml.txt | 9.06 KB |

Comments
How about drupal 5? I've
Tue, 2008-06-17 04:37 — internal (not verified)How about drupal 5?
I've tried your method in drupal 5. I think the key point is to include your test.inc.txt in simpletest. I've set it up. But when I run upload_tests.test as simpletest, the console shows one line echo message, no error message and any test running in result view. Can it be done in drupal 5? Thanks.
I haven't tried it in drupal
Sat, 2008-06-28 12:59 — Roel De MeesterI haven't tried it in drupal 5.
And a few weeks ago i retried my steps on a fresh system and i didn't get it going either.
I should invest this setup a bit more. If i have time.
I will add a disclaimer on top of the post..
I had a few problems
Thu, 2008-04-24 15:53 — John Fiala (not verified)I had a few problems following your instructions - here's what they were.
You indicate that you have to point the simpletest eclipse plugin to the test/test.inc file before you actually have the user download the file to use. Unfortunately, I also wasn't able to download the file from your site - luckily Kevin had a copy I could use.
The changes you indicated making in plugin.xml don't match what's in the file - instead of finding <extension>php</extension> I found an attribute 'extension="php"'.
Additionally, you mention that you've got the 0.2.3 version of the plugin - but when I did an install following your instructions, I only got the 0.2.1 version.
Finally - it doesn't seem to work. When I had it all up and did a Run->as Simpletest, I got the error "Fatal error: Class 'EclipseReporter' not found in /tmp/Simpletest64978.php on line 1" - I tried googling for the error and didn't see anything helpful. Do you know what causes that?
Thanks!
Could you try using the
Mon, 2008-05-05 23:31 — Roel De MeesterCould you try using the provided plugin.xml?
I checked my version of the plugin and it is indeed 0.2.3,
Apparantely the update site at http://simpletest.org/eclipse/ only provides version 0.2.1 while the sourceforge download page contains version 0.2.3.
http://sourceforge.net/project/showfiles.php?group_id=76550&package_id=1...
I've updated my post to reflect my current configuration
Interesting, I should try
Thu, 2008-04-24 13:18 — Stefaan Lippens (not verified)Interesting, I should try this when I'll get more familiar with eclipse.
btw: I get "500 Internal Server Error" for the attachments
500 Internal Server Error
Mon, 2008-05-05 23:49 — Roel De Meester500 Internal Server Error has been resolved.