Unit Tests

From PKP Wiki
Revision as of 15:09, 19 October 2009 by Jerico.dev (Talk | contribs) (Beginning a unit test documentation)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Installing and Configuring your Test Environment


You'll need PEAR installed for the following steps to work. If you are on Linux simply install the corresponding package provided by your packaging system. If you are on Windows execute the "go-pear.bat" in the PHP installation directory and follow the on-screen instructions.

If you are on Linux you may also find some or all of the other required software pre-packaged for your distribution. Please check that before installing software manually.


On the command line execute

pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit

PKP Unit Test Framework

The PKP unit test framework can be checked out as part of the pkp library. You find it in pkp/tests.

Eclipse integration

If you use Eclipse then you should install an external tool runner to integrate PHPUnit. This is a Wiki. Please feel free to add similar configurations for other CASE tools.

"The first step is to create the launch configuration which tells Eclipse where to find PHP, PHPUnit and the test you want to run. To create a launch configuration, start up Eclipse and, from the top menu bar click run->external tools->open external tools dialogue. On that page click the New launch configuration icon in the top left hand corner. I've shown a sample launch configuration below. The string in the top box (/mnt/workspace/PHP/php53/saapi/cli/php) is the name of my PHP executable. On your system this might be something like /usr/local/php (Linux) or on Windows it will be the location of your php.exe. In the next box you add the text exactly as I have shown, Eclipse will resolve this to work space that you are using. In the final (lowest box) you need the location of your PHPUnit executable followed by the srting ${resource_path}, ${resource_path} is resolved by Eclipse to the entity that you will highlight when you want to execute a test (see later)."

File:Screenshot-External Tools .png

Text and screenshot in this section are reproduced without alteration from PHPUnit Wiki in accordance with Creative Commons License. Thanks to zoe.

Installing and Configuring the Build Environment


On the command line execute

pear channel-discover pear.phing.info
pear install phing/phing