SaunterPHP is the PHP version of the Saunter test framework and is based on the PHPUnit runner.
Install
SaunterPHP is distributed through PEAR which means you need to have a working PEAR installation (which can be a bit of a challenge…). But once you have that in place;
pear channel-discover element-34.github.com/pear pear install -f element-34/SaunterPHP |
The above assumes you have put pear in your path and that you have permissions on the machine to execute it. sudo or changing uses may be necessary otherwise.
Note: There have been reports of pear returning a 404 when trying the channel-discovery command. This appears to be happening when you are not running PEAR 1.9.4 (which at this time is the current one). To tell PEAR to upgrade itself, the following command will work.
pear upgrade pear |
Initialize
SaunterPHP has certain opinions baked into it in terms of the existence of certain files in certain places. But don’t worry, it knows about these opinions and it will create the basic set for you. On linux and osx the SaunterPHP script is called saunter, and on windows there is a bit of a wrapper for it called saunter.bat. In both cases, this script is installed in the main script location for your PHP install. You likely want to add this directory to your path if it is not there already.
The –new flag will create in the current directory a base installation that can be commit into version control.
Linux/OSX
saunter --new |
Windows
saunter.bat --new |
Configure
Emulating a practice popularized by the Ruby-on-Rails community, there is a conf/saunter.inc.default file. Create a copy of it as conf/saunter.inc. This non-default version will have machine specific information in it and should not be committed to version control. The default version should however.
Create
Saunter distinguishes between Scripts and Page Objects. Think of the difference as Scripts are the What and Page Objects as the How. There will be a lot more detail provided around how to create both of these, but for this, it is important to state that they too have a specific place.
- Scripts -> scripts/
- Page Objects -> includes/pages/
Run
SaunterPHP makes explicit use of PHPUnit’s group docstring.
saunter --group website |
will run all the scripts that have been marked as being website ones.
Report
While Saunter can be run locally on any machine (and should while you are creating your scripts), it is meant to be run inside a Continuous Integration server. To facilitate this, run results are logged in the Ant JUnit format in the logs directory with the most recent one always available as latest.xml. This is the artifact to consume and archive after each run.
Examples
Sometimes the easiest way to figure something out is to look at working examples. While the examples are not included in the distribution, there are complete, working SaunterPHP projects online in github.
Class Documentation
Coming Soon!
Bugs
SaunterPHP has been used in a couple organizations, but that does not mean that there are not bugs to be discovered. If you encounter one, don’t be quiet about it. Either
- Log it at Github
- Email help@element34.ca
