E(z)asy coupling
Running unit tests of eZ Components inside of Eclipse PDT
Installing eZ Components
First things first, I checkout the 'scripts/' folder and the complete eZ Components library ('/trunk' folder) from their open svn repository.
You can either do this on the shell and create a new project in Eclipe referring to an extsting source or checkout the sources when creating a new project using the subversion plugin in of your choise.
After the checkout was completed the eZ Components need to be setup by running
#>cd /PATH/TO/YOUR/ECZ/TRUNK
#>../scripts/setup-env.shAs you for sure have recognized the 'setup-env.sh' has to be executed from within your 'trunk' folder. It sets up a proper environment for the eZ Components.
My friend recently switched to Karmic - the latest Ubuntu release - he was very confused that it were not possible to create a new project within Eclipse. The IDE simply does not replied to mouse clicks in the 'New Project' assistant. But using the TAB and SPACE keys to navigate and confirm turned out to be a good workaround. Nevertheless I filed a bug report in the Eclipse Bugtracker.
Running the tests
As soon as I was able to setup the eZ Components project in Eclipse I started investigating how to run the unit test of the eZ Components. My friend was very helpful here. He told me if I want to run all tests of a component I only need to add the phpUnit sources to the include_path of my PHP installation and run the runtests.php
#>cd /PATH/TO/YOUR/EZC/TRUNK
#>php -c /PATH/TO/php.ini /UnitTest/src/runtests.php NAME_OF_COMPONENTFirstly I tried to run the tests on the bash with the following output
#> php -c /usr/local/php5/lib/php_phpunit.ini UnitTest/src/runtests.php Feed
PHPUnit @package_version@ by Sebastian Bergmann.
eZ Components:
Feed:
ezcFeedTest: .................................I..
ezcFeedExtendTest: ................
ezcFeedAtomRegressionGenerateTest: ................................................
ezcFeedAtomRegressionParseTest: ................................................
ezcFeedRss1RegressionGenerateTest: .........................................
ezcFeedRss1RegressionParseTest: ...............................................
ezcFeedRss2RegressionGenerateTest: ................................................
ezcFeedRss2RegressionParseTest: ................................................
Time: 14 seconds
OK, but incomplete or skipped tests!
Tests: 813, Assertions: 855, Incomplete: 1.Nice. Seems all up and running - now to the IDE.
Setup a runner in the External Tools Framework
Image of the Run dialog of Eclipse PDT showing the set up
Since we want to run the unit tests using the External Tools Framework of the Eclipse IDE we need to set up an appropriate runner. To do so we open the 'External Tools Configurations' dialog (Run > External Tools > External Tools Configurations) and create a 'new launch configuration' by choosing the proper icon in the icon bar (it should be the one on the outer left). The image on the left shows you the necessary settings to run the tests.
To run the tests mark the component in the 'navigator' or 'PHP Explorer' window and choose the recently configured launcher from the 'Run' menu. The output PHPUnit generates will appear in the 'Console' of Eclipse.
Have fun!
Trackbacks
Comments
Fields with bold names are mandatory.