Bastian's Blog ~~~~~~~~~~~~~~ :Author: lapis :Date: Sun, 19 Dec 2010 15:34:43 +0100 :Revision: 17 :Copyright: CC by-nc-sa ================ E(z)asy coupling ================ :Keywords: eclipse, PDT, PHP, ezC, ez Components, Unittests, testing, External Tools Framework :Description: :Abstract: Inspired by the latest conference a friend of mine asked me to investigate how to run the eZ Components unittests using the External Tools Framework of the Eclipse IDE. I promised him to take a look at this… 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. .. _svn: svn co http://svn.ez.no/svn/ezcomponents/ 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.sh As 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. .. _Karmic: http://ubuntu.com .. _bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=295807 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_COMPONENT .. _phpunit: http://phpunit.de Firstly I tried to run the tests on the bash with the following output .. include:: 012_bashoutput.txt :literal: Nice. Seems all up and running - now to the IDE. Setup a runner in the External Tools Framework ++++++++++++++++++++++++++++++++++++++++++++++ |ezClaunncher| .. |ezClaunncher| image:: ../images/articles/thumbs/ezCLauncher.png :alt: Image of the Run dialog of Eclipse PDT showing the set up :target: ../images/articles/ezCLauncher.png :class: right 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 ========