PHPUnit is the test framework of our choice (surprise, surprise) and we are using the sfPHPUnit2Plugin for all our projects. If you do not now this plugin you may first read another post where the usage and features are described in detail.
All requirements in short:
* Hudson has to be installed
* Hudson plugin xUnit Plugin has to be installed
* the symfony project needs the sfPHPUnit2Plugin
* PHPUnit has to be installed on your test server
Ok, here the configuration steps of the hudson project:
1. Configure your project
Configure standard settings for a hudson project like source-code management settings or email notifications. Please check the official docs if you do not know how to handle this.
2. Add a shell build step
Building a symfony project in a test environment is pretty easy. With the help of some shell commands the project is completely configured and ready for testing. Those shell commands may be entered in the build step section of the hudson project. Defining the correct commands is the main part during the configuration process.
Our configuration looks like this:
1. cd $WORKSPACE/trunk
2. sh _deployment/install_test.sh
3. php symfony cc
4. php symfony phpunit:test-all --configuration --options="--log-
5. junit=build/testresult_$BUILD_NUMBER.xml" cd build
6. ln -s -f testresult_$BUILD_NUMBER.xml currentTestResult.xml
1. Jump in the project root of the project
2. Install the project on the test server with the help of a internal shell script. This step includes for example the generation of the databases.yml.
3. Clear the symfony cache (always a good choice)
4. Run all PHPUnit tests including unit and functional tests. The test result is written in a jUnit compatible logfile (needed for the xUnit Plugin).
5. Jump in the build directory, which is internally used by Hudson
6. Symlink the latest testresult
3. Configure Post-Build-Action
After the xUnit Plugin is installed correctly, an additional PHPUnit Pattern field should be displayed in the post build action section. In this field has to be entered:
1 trunk/build/currentTestResult.xml
The options “Fail the build if test results were not updated this run” and “Delete temporary JUnit file” should be both checked.
The xUnit Plugin takes the currentTestResult.xml file, which was previously created with the help of the sfPHPUnit2Plugin and analyzes it. When everything works fine, you should be able to review the created test reports.
Here some screenshots how this result could look like.
Build history:
Trend graph of the test results:
You can find the original post here : http://dev.esl.eu/blog/category/symfony/
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.