Actions

Difference between revisions of "Running Automated Tests for the Joomla CMS"

From Joomla! Documentation

(add DbUnit install)
(Running Unit Tests)
Line 94: Line 94:
  
 
== Running Unit Tests ==
 
== Running Unit Tests ==
Once PHPUnit is installed, you can run the unit tests. To run a unit test from the command line:
+
===Run Suite from XML File===
# Change to the folder <code><joomla root>/tests/unit</code>
+
Once PHPUnit is installed, it's easy to run the unit tests. The command that runs the tests is called <code>phpunit</code>. This file is found in your PHP folder. For example, in Windows with Xampp, it would be <code>c:/xampp/php/phpunit</code>. In Linux, with Xampp, it might be <code>/opt/lampp/bin/phpunit</code>. If you add this to your operating system path, you can execute it from any folder without using the full path name.
# Execute the command <code>phpunit <test name or folder></code>
+
For example, to execute the test called "suite\libraries\joomla\utilities\JStringTest.php", you would type the command
+
* <code>phpunit suite\libraries\joomla\utilities\JStringTest.php</code>
+
  
When you run this, you will see output similar to the following:
+
When you run <code>phpunit</code> it looks for a PHPUnit configuration XML file (either <code>phpunit.xml</code> or <code>phpunit.xml.dist</code>). The CMS unit tests are run from the Joomla root folder, where you will find the <code>phpunit.xml.dist</code> file. This file is included in the Git repository and can be used as is or customized (by making a copy called <code>phpunit.xml</code>).  
<pre>
+
C:\xampp\htdocs\joomla_development\j16_trunk\tests\unit>phpunit suite\libraries\
+
joomla\utilities\jstringtest.php
+
PHPUnit 3.4.11 by Sebastian Bergmann.
+
  
............................................................ 60 / 89
+
To run all of the unit tests from the command line:
.............................
+
# Change Joomla root folder
 +
# Execute the command <code>phpunit</code>.  
  
Time: 26 seconds, Memory: 7.00Mb
+
The following example runs the entire unit test suite using the <code>phpunit.xml.dist</code> file in Windows.
  
OK (89 tests, 89 assertions)
+
C:\xampp\htdocs\joomla_development\cms-trunk>phpunit
</pre>
+
PHPUnit 3.6.11 by Sebastian Bergmann.
The dots indicate a successful test. If you have errors or failures, they will show as "E" or "F" letters and a detailed message for each will show.
+
 +
Configuration read from C:\xampp\htdocs\joomla_development\cms-trunk\phpunit.xml.dist
 +
 +
IIIIIIII....................SS.......S.........................  63 / 234 ( 26%)
 +
............................................ISSISSSSSSSSSSI.... 126 / 234 ( 53%)
 +
...IIIIIIIIII.I.I.I.IIIIIIIIIIIIIIIII..IIIIIIIIS.IIIIII..II..SS 189 / 234 ( 80%)
 +
SI..I........I...I...I...I.III.I.............
 +
 +
Time: 13 seconds, Memory: 21.25Mb
 +
 +
OK, but incomplete or skipped tests!
 +
Tests: 234, Assertions: 281, Incomplete: 67, Skipped: 19.
 +
 +
Generating code coverage report in Clover XML format ... done
 +
 +
Generating code coverage report in HTML format ... done
  
You can execute all of the tests in a folder by specifying a folder instead of a file. For example, to run all of the tests in the folder "suite\libraries\joomla\utilities", you would enter
+
The dots indicate a successful test. If you have errors or failures, they will show as "E" or "F" letters and a detailed message for each will show. If you are generating code coverage or other logs, you can see the folders where these are generated in the XML file. In the default file, all of the logs are generated in <code>build/logs</code>, with coverage information in a folder called <code>coverage</code>.
* <code>phpunit suite\libraries\joomla\utilities</code>
+
  
This command will produce output similar to that shown below:
+
You can create your own phpunit.xml file by copying the phpunit.xml.dist file and making the desired changes. For example, if you don't want to create the coverage information, remove the <code>log type="coverage-html"</code> element.
<pre>
+
C:\xampp\htdocs\joomla_development\j16_trunk\tests\unit>phpunit suite\libraries\
+
joomla\utilities
+
PHPUnit 3.4.11 by Sebastian Bergmann.
+
  
............................................................  60 / 317
+
===Run Selected Unit Tests===
............................................................ 120 / 317
+
You can run unit tests one at a time or by folder. The following example runs all of the tests in the <code>libraries/feed</code> folder:
............................................................ 180 / 317
+
............................................................ 240 / 317
+
............................................................ 300 / 317
+
...FFFF..........
+
  
Time: 27 seconds, Memory: 11.00Mb
+
C:\xampp\htdocs\joomla_development\cms-trunk>phpunit tests/unit/suites/libraries
 +
/feed
 +
PHPUnit 3.6.11 by Sebastian Bergmann.
 +
 +
Configuration read from C:\xampp\htdocs\joomla_development\cms-trunk\phpunit.xml
  
There were 4 failures:
+
....................SS.......S................................... 65 / 99 ( 65%)
 +
..................................
  
1) JUtilityTest::testGetHash
+
Time: 1 second, Memory: 8.25Mb
Failed asserting that two strings are equal.
+
--- Expected
+
+++ Actual
+
@@ @@
+
-ce114e4501d2f4e2dcea3e17b546f339
+
+0cbc6611f5540bd0809a388dc95a615b
+
  
 +
OK, but incomplete or skipped tests!
  
2) JUtilityTest::testGetToken with data set "default" (NULL, false)
+
You can also specify a single test simply by specifying it's full path name in the command.
Failed asserting that <string:adca734617ce829cc979492d6d037416> matches expected
+
<boolean:false>.
+
 
+
 
+
3) JUtilityTest::testGetToken with data set "false" (false, false)
+
Failed asserting that <string:adca734617ce829cc979492d6d037416> matches expected
+
<boolean:false>.
+
 
+
 
+
4) JUtilityTest::testGetToken with data set "true" (true, true)
+
Expectation failed for method name is equal to <string:getFormToken> when invoke
+
d 1 time(s).
+
Method was expected to be called 1 times, actually called 0 times.
+
 
+
 
+
FAILURES!
+
Tests: 317, Assertions: 361, Failures: 4.</pre>
+
In this case, we have 4 test failures with details about each.
+
  
 
== System Tests ==
 
== System Tests ==

Revision as of 20:57, 1 November 2012

Contents

Quill icon.png
Page Actively Being Edited!

This article is actively undergoing a major edit for a short while.
As a courtesy, please do not edit this page while this message is displayed. The user who added this notice will be listed in the page history. This message is intended to help reduce edit conflicts; please remove it between editing sessions to allow others to edit the page. If this page has not been edited for several hours, please remove this template, or replace it with {{underconstruction}} or {{incomplete}}.

Introduction

This article has been updated as of November 2012 to reflect the latest information for running unit and system tests for Joomla version 3.0.

When you checkout the master branch of Joomla from Github.com (https://github.com/joomla/joomla-cms) you will see a folder called "tests". This folder contains unit and system tests for the CMS. The unit tests use PHPUnit and the system tests use PHPUnit and Selenium. The unit tests perform tests on the Joomla library files (libraries/cms). The Selenium system tests run Joomla! from a browser and test it as a user would.

Before you can run the tests, you need to install some programs on your local workstation, as documented below. This document explains how to run the these tests from your local workstation.

Install PHPUnit

Both the unit and system tests rely on PHPUnit. PHPUnit is a testing framework that requires PHP to be installed on the local workstation. On most PHP installations, PNPUnit can be installed using the PEAR installation process, so that is what we document here. As of November 2012, PHPUnit 3.6 is recommended. PHP version 5.3.8 or later is required to run the Joomla system tests. You can run the unit tests with PHP 5.3.3 or later.

The latest installation instructions for PHPUnit are here: http://www.phpunit.de/manual/3.6/en/installation.html.

The PEAR commands are as follows:

  • pear config-set auto_discover 1
  • pear install pear.phpunit.de/PHPUnit
  • pear install pear.phpunit/DbUnit
  • pear install phpunit/PHPUnit_Selenium

For example, on XAMPP version 1.8.1 on Windows, you would do the following commands and install PHPUnit version 3.7.8. First you set pear for auto discover, as follows:

C:\xampp\php>pear config-set auto_discover 1
config-set succeeded

Next you install PHPUnit. This will work for a few minutes and should show something similar to the following:

C:\xampp\php>pear install pear.phpunit.de/PHPUnit
Attempting to discover channel "pear.phpunit.de"...
downloading channel.xml ...
Starting to download channel.xml (804 bytes)
....done: 804 bytes
Auto-discovered channel "pear.phpunit.de", alias "phpunit", adding to registry
Attempting to discover channel "pear.symfony.com"...
downloading channel.xml ...
...
... (some lines omitted to save space)
...
install ok: channel://pear.phpunit.de/File_Iterator-1.3.3
install ok: channel://pear.phpunit.de/Text_Template-1.1.4
install ok: channel://pear.phpunit.de/PHP_Timer-1.0.4
install ok: channel://pear.symfony.com/Yaml-2.1.3
install ok: channel://pear.phpunit.de/PHP_TokenStream-1.1.5
install ok: channel://pear.phpunit.de/PHP_CodeCoverage-1.2.6
install ok: channel://pear.phpunit.de/PHPUnit_MockObject-1.2.1
install ok: channel://pear.phpunit.de/PHPUnit-3.7.8

Next, install DbUnit as follows:

C:\xampp\php>pear install phpunit/DbUnit
downloading DbUnit-1.2.1.tgz ...
Starting to download DbUnit-1.2.1.tgz (41,892 bytes)
............done: 41,892 bytes
install ok: channel://pear.phpunit.de/DbUnit-1.2.1

Finally, to run the system tests you need to install the Selenium extension for PHPUnit, as follows:

C:\xampp\php>pear install phpunit/PHPunit_Selenium
downloading PHPUnit_Selenium-1.2.10.tgz ...
Starting to download PHPUnit_Selenium-1.2.10.tgz (37,389 bytes)
..........done: 37,389 bytes
install ok: channel://pear.phpunit.de/PHPUnit_Selenium-1.2.10

At this point, PHPUnit should be set up and you can proceed to the next section.

Troubleshooting PHPUnit Installation

If you get an error that your PEAR version is too low, run:

  • pear upgrade pear

and repeat pear install phpunit/PHPUnit . Windows users not using WAMP or XAMPP can use the same procedure, with substituting the location of your PHP installation for cd c:\xampp\php.

In Ubuntu Linux, use the following commands to install PHPUnit:

  • sudo apt-get install php-pear
  • sudo pear channel-update pear.php.net
  • sudo pear upgrade-all
  • sudo pear channel-discover pear.phpunit.de
  • sudo pear channel-discover components.ez.no
  • sudo pear channel-discover pear.symfony-project.com
  • sudo pear install -a phpunit/PHPUnit

In Mac OSX with XAMPP, use the following commands to install PHPUnit:

  • $sudo /Applications/XAMPP/xamppfiles/bin/pear channel-discover pear.phpunit.de
  • $sudo /Applications/XAMPP/xamppfiles/bin/pear channel-discover pear.symfony-project.com
  • $sudo /Applications/XAMPP/xamppfiles/bin/pear channel-discover components.ez.no
  • $sudo /Applications/XAMPP/xamppfiles/bin/pear install -a phpunit/PHPUnit

If you are using MAMP, substitute the path to your PHP pear folder for /Applications/XAMPP/xamppfiles/bin/.

More detailed instructions can be found here: http://www.phpunit.de/manual/3.0/en/installation.html.

Running Unit Tests

Run Suite from XML File

Once PHPUnit is installed, it's easy to run the unit tests. The command that runs the tests is called phpunit. This file is found in your PHP folder. For example, in Windows with Xampp, it would be c:/xampp/php/phpunit. In Linux, with Xampp, it might be /opt/lampp/bin/phpunit. If you add this to your operating system path, you can execute it from any folder without using the full path name.

When you run phpunit it looks for a PHPUnit configuration XML file (either phpunit.xml or phpunit.xml.dist). The CMS unit tests are run from the Joomla root folder, where you will find the phpunit.xml.dist file. This file is included in the Git repository and can be used as is or customized (by making a copy called phpunit.xml).

To run all of the unit tests from the command line:

  1. Change Joomla root folder
  2. Execute the command phpunit.

The following example runs the entire unit test suite using the phpunit.xml.dist file in Windows.

C:\xampp\htdocs\joomla_development\cms-trunk>phpunit
PHPUnit 3.6.11 by Sebastian Bergmann.

Configuration read from C:\xampp\htdocs\joomla_development\cms-trunk\phpunit.xml.dist

IIIIIIII....................SS.......S.........................  63 / 234 ( 26%)
............................................ISSISSSSSSSSSSI.... 126 / 234 ( 53%)
...IIIIIIIIII.I.I.I.IIIIIIIIIIIIIIIII..IIIIIIIIS.IIIIII..II..SS 189 / 234 ( 80%)
SI..I........I...I...I...I.III.I.............

Time: 13 seconds, Memory: 21.25Mb

OK, but incomplete or skipped tests!
Tests: 234, Assertions: 281, Incomplete: 67, Skipped: 19. 

Generating code coverage report in Clover XML format ... done

Generating code coverage report in HTML format ... done

The dots indicate a successful test. If you have errors or failures, they will show as "E" or "F" letters and a detailed message for each will show. If you are generating code coverage or other logs, you can see the folders where these are generated in the XML file. In the default file, all of the logs are generated in build/logs, with coverage information in a folder called coverage.

You can create your own phpunit.xml file by copying the phpunit.xml.dist file and making the desired changes. For example, if you don't want to create the coverage information, remove the log type="coverage-html" element.

Run Selected Unit Tests

You can run unit tests one at a time or by folder. The following example runs all of the tests in the libraries/feed folder:

C:\xampp\htdocs\joomla_development\cms-trunk>phpunit tests/unit/suites/libraries
/feed
PHPUnit 3.6.11 by Sebastian Bergmann.

Configuration read from C:\xampp\htdocs\joomla_development\cms-trunk\phpunit.xml
....................SS.......S................................... 65 / 99 ( 65%)
..................................
Time: 1 second, Memory: 8.25Mb
OK, but incomplete or skipped tests!

You can also specify a single test simply by specifying it's full path name in the command.

System Tests

Before you can run the system tests, you need to install and set up the Selenium RC package and configure your test environment, as shown below.

Install Selenium RC

Selenium RC is the package that allows you to run Selenium tests from PHP or other programming languages. To install it, just go to the Selenium site http://seleniumhq.org/projects/remote-control and download the package. Then unzip the file into a folder.

For example, in Windows if you create a folder called C:\selenium and unzip this file there, it will create a folder called selenium-server-1.0.1. In that folder, create a Windows bat file (such as selenium.bat though the name does not matter) or Linux shell script that runs the following command:

java -jar selenium-server.jar -browserSessionReuse

If the Java executable is not on your path, then you will need to indicate the full path to it, like the following:

"c:\program files (x86)\Java\jre6\bin\java.exe" -jar selenium-server.jar -browserSessionReuse

Note the argument browserSessionReuse is used to allow you to run multiple tests without closing and re-opening the browser each time. Save this file so you can easily find and execute it when needed.

This program needs to be running in the background before you can run any Selenium functional tests.

If You are using Firefox 3.6.x, be sure to install Selenium RC version 1.0.3 (released February 2010) or later. Earlier versions of Selenium RC have problems running in Firefox 3.6.x.

Create a Selenium Configuration File

To run the Selenium tests, we have to tell Selenium how to navigate and login to your local Joomla! installation. This is done by creating a PHP file called configdef.php. The Joomla! download includes a file called tests/system/servers/config-def.php-dist. This is a sample file that you can use to create the real file. Copy this file to a file called tests/system/servers/configdef.php and edit it to reflect your test systems configuration. There are comments in the file that tell you how to do this.

Run the System Test Suite

At this point, we are ready to actually run the tests. There are two steps to running a test. First, you need to make sure the Selenium RC process is running in the background. To do this, just execute the command (bat file or shell script) you created when you installed Selenium RC. This will continue to run until you cancel it.

Once Selenium RC is running, you need to execute the functional tests. There are several ways you can do this.

To run all tests from the command line in Windows, change to the tests/system folder and run the following command (the phpunit.bat file comes from the PHPUnit installation):

phpunit.bat --bootstrap servers\configdef.php suite\TestSuite.php

In Linux, the command is:

phpunit --bootstrap servers/configdef.php suite/TestSuite.php

This will run all of the tests in the TestSuite.php file. You should see a series of messages display in the console telling you what tests are being run and what the tests are doing. You should also see two browser windows open. One will display Selenium commands that are being executed. The other will show the Joomla! website and the various screens that are being opened and closed as the tests are run.

The tests will run for a few minutes, depending on the speed of your system. When they are done, you will get a summary display showing how many tests were run and whether there were errors or failures. If there are errors or failures, the line of code from the test program that generated the error or failure will also show.

An error occurs when the test encounters an actual PHP error. A failure occurs when the test gets a result that is different than expected.

Tips

  • Make sure you run the tests on a clean database that has been installed with sample data. If you have made database changes, you should re-install Joomla! or otherwise put the database back to it's original post-installed state.
  • If you find errors or failures when you run the tests, you can run the tests against the Joomla! trunk to see if the problems are in trunk or just in your branch.
  • If you maintain more than one local Joomla! project (for example, one for trunk, another for a branch), you will need to make sure to have a configdef.php file for each that has the right path and login information. You can watch the browser window while the tests are running to make sure you are testing the URL that you expect.
  • If TestSuite fails with a red Error message when importing sample data (a Joomla install is the first step in TestSuite), you may need to increase the time allowed for the sample data import in the following line 57 of tests/system/suite/doInstall.php.
if ($second >= 15) $this->fail("timeout");

Eclipse Users

In Eclipse, you can set up Debug and External Tools launch configurations that make it easy to debug or run unit and system tests.

Run a Unit Test

You can create an External Tools launch configuration that lets you run any unit test simply by pointing to the test file and pressing the Run button. Here are the steps for Windows:

  • Open the Run→External Tools→External Tools Configuration menu and press the button labeled "New Launch Configuration".
  • Enter a descriptive name, such as "Run Selected Unit Test".
  • Enter the location that points to your phpunit.bat file (for example, c:\xampp\php\phpunit.bat).
  • Set the Working Directory to ${project_loc}\tests\unit
  • Set the arguments to c:\xampp\php\phpunit --verbose ${resource_loc}. You can leave out the "--verbose" if you prefer the more compact display.

This is shown in the screenshot below.

Unit test tutorial screenshot 20100405-01.png

Here are the steps for Mac OSX using XAMPP:

  • Enter a descriptive name, such as "Run Selected Unit Test".
  • Enter the location that points to your phpunit executable file. For XAMPP, this will be /Applications/XAMPP/xamppfiles/bin/phpunit).
  • Set the Working Directory to ${project_loc}/tests/unit
  • Set the arguments to --verbose "${resource_loc}". You can leave out the "--verbose" if you prefer the more compact display.

This is shown in the screenshot below.

Unit test tutorial screenshot 201000708-01.png

To run a unit test:

  1. Select a unit test, either by selecting it in the PHP Explorer view or in the edit area of Eclipse.
  2. Run the External Launch configuration by selecting it from the drop-down list next to the External Launch Configuration button in the toolbar (shown below).

Unit test tutorial screenshot 20100406-01.png

Note that a test might normally take a 30-60 seconds to run. The output of the test will show in the Eclipse console.

Run All Tests in a Folder

You can run all of the unit tests in a folder using this same launch configuration. Just select a folder instead of a test file and all of the unit tests in that folder will run.

Setting Up For Debugging

Make Sure XDebug is Installed

As you would expect, XDebug must be installed and configured for use with Eclipse. See Setting_up_your_workstation_for_Joomla!_development#Edit_PHP.INI_File for detailed instructions.

Add PEAR Library to Workspace

Before you can debug a unit or system test, you have to add the PEAR library to your project or workspace. In this example, we will add PEAR to our workspace. That way, all projects will automatically have access to PHPUnit.

Here are the steps:

  • Select Window→Preferences→PHP→PHP Libraries.
  • Press the New button and add PEAR as shown below. Be sure to press the checkbox labeled "Add to environment".

Unit test tutorial screenshot 20100406-01a.png

  • Press OK, then press the Add External folder button and browse to your PEAR folder, as shown below. In this example, the folder is in c:\xampp\php\PEAR.

Unit test tutorial screenshot 20100406-01b.png

  • Press OK and the screen should show the external folder, as shown below, with the correct file path for your workstation.

Unit test tutorial screenshot 20100406-01c.png

After this is completed go to project preferences - > Properties -> PHP Include path -> Libraries tab -> Add library. Select User library in popup, click Next and mark Pear[enviroment] as checked.

Also make sure your project folder is added in Source tab of your project's PHP Include path.

Configure the PHP Executable

Normally, you will want to debug unit and system tests as PHP scripts (as opposed to web pages). Before you can do this, you need to configure a PHP Executable in Eclipse. This is done as follows:

  • Select Window→Preferences→PHP→PHP Executables. The screen below will show.

Unit test tutorial screenshot 20100406-05.png

  • Press Add and complete the screen as shown below, substituting the correct file paths for your workstation.

Unit test tutorial screenshot 20100406-06.png

At this point, your workstation is set up for PHPUnit debugging. Now you just have to create the debug configurations as shown in the next section.

Debug a Single Unit Test

Once you have PEAR added to your libraries, it is easy to set up a debug configuration that allows you to debug any unit test. Here are the steps:

  • Press the drop-down arrow next to the Debug button and select Debug Configurations from the menu, as shown below.

Unit test tutorial screenshot 20100406-02.png

  • In the Debug Configurations window, make sure that PHP Script is selected and press the New Launch configuration button as shown below.

Unit test tutorial screenshot 20100406-17.png

  • Fill out the PHP Script tab of the Debug Configurations as shown below.
    • Name: a descriptive name like "Debug Selected Unit Test"
    • PHP Debugger: XDebug
    • PHP Executable: The one you set up earlier (there will only be one)
    • PHP File: Use the Browse button to browse to the phpunit.php file in your tests/system folder.

Unit test tutorial screenshot 20100406-10.png

  • Select the PHP Script Arguments tab and enter --verbose ${selected_resource_loc} as shown below.
    • The "--verbose" option allows you to see more details when the tests are run.
    • The "${selected_resource_loc}" passes the currently selected file at runtime, so you can use this configuration just by selecting the desired file and then running it.

Unit test tutorial screenshot 20100406-11.png

  • Finally, select the Common tab and check the Debug checkbox under "Display in favorites menu", as shown below.

Unit test tutorial screenshot 20100406-09a.png

At this point, you are ready to debug any unit test. All you need to do is:

  1. Select the desired test file either in the PHP Explorer view or in the editor.
  2. Select Debug Configurations from the Debug drop-down button and select the "Debug Selected Unit Test" option. Once you have run this once, it will show on your Debug favorites menu.

Run a Single System Test

You can create a configuration to make it easy to run any single test in your project. To do this:

  • Open the Run→External Tools→External Tools Configuration menu and press the button labeled "New Launch Configuration"
  • Enter the location that points to your phpunit.bat file (for example, c:\xampp\php\phpunit.bat). On Linux systems, this might be called "phpunit".
  • Set the Working Directory to ${project_loc}/tests/system
  • Set the arguments to --bootstrap servers/configdef.php ${selected_resource_loc}.

This is shown in the screenshot below.

Unit test tutorial screenshot 20100406-14.png

To use this configuration,

  1. Make sure the Selenium RC process is running (for example, by running the "selenium.bat" file you created when you installed Selenium RC earlier)
  2. Select the desired test file by clicking on it in the PHP Explorer view or in the edit area
  3. Start this launch configuration

The selected test file will be run and you will see the browser session open and run the test script. The test results will be reported in the Eclipse console.

Debug a Single System Test

The steps for creating a Debug Configuration for a Selenium system test are similar to those for the unit test.

  • Open Debug Configurations from the drop-down menu next to the Debug Button on the toolbar, as shown below.

Unit test tutorial screenshot 20100406-02.png

  • In the Debug Configurations window, make sure that PHP Script is selected and press the New Launch configuration button as shown below.

Unit test tutorial screenshot 20100406-17.png

  • Fill out the Debug Configurations dialog box as shown below:
    • Name: A descriptive name for the configuration, like "Debug Selected System Test".
    • PHP Debugger: XDebug
    • PHP Executable: The one you defined earlier (there probably is only one).
    • PHP File: Browse to the phpunit.php file in your tests/system folder.

Unit test tutorial screenshot 20100406-12.png

  • Select the PHP Script arguments and fill this out as shown below.
    • --bootstrap servers/configdef.php points to the configuration file that passes the login information to Selenium.
    • "${selected_resource_loc}" passes the location of the currently selected file in Eclipse to the command line.

Unit test tutorial screenshot 20100406-13.png

  • Finally, select the Common tab and check the Debug option in the Display in favorites menu. This will add this configuration to your favorites.

Unit test tutorial screenshot 20100406-09a.png

At this point, you can debug any system test. To do so:

  1. Make sure the Selenium RC program is running in the background.
  2. Select the desired test by selecting it in the PHP Explorer or in the editor.
  3. Run this Debug Configuration by selecting the drop-down arrow next to the Debug button, then Debug Configurations, then the "Debug Selected System Test" configuration created above.

Run the System Test Suite

To create a launch configuration to run the Test Suite of the currently-selected Eclipse project:

  • Enter the location that points to your phpunit.bat file. If you are running Linux, this file might be called phpunit.
  • Set the Working Directory to ${project_loc}/tests\system
  • Set the arguments to --bootstrap servers/configdef.php suite/TestSuite.php.

This is shown in the screenshot below.

Unit test tutorial screenshot 20100406-15.png

The console output will show in the Eclipse console. Note that you still need to have the Selenium RC program running in the background first, before running the suite. Note that you need to select a file in the current project before running this command so the {project_loc} variable is set correctly.