Complete example for Eclipse RCP 3.6.2/P2/Junit tests - eclipse-rcp

Does anyone know of a good complete example (source, scripts, jobs)
that covers all the following?
building an Eclipse RCP product with many features
generating a P2 repository
running JUnit tests
using Eclipse 3.6.2
building for few platforms with the Delta Pack
We are using the Headless PDE build system, but are open
to change to Buckminster or Maven.
Thanks,
Daniel Coupal

Take a look at Kai's MP3 Manager and the associated blog.

Building with p2 for multiple platforms is fairly easy with eclipse 3.6.2. By default, you get your RCP product, your features, a p2 repository, and multiple platform zips. See http://pweclipse.blogspot.com/2010/09/simple-rcp-product-build.html for the main steps.
We use a masterBuild.sh bash [1] script to run our build, publish it, and then run our automated tests. We copied the runtests [2] and test.xml [3] out of the standard Eclipse Test Framework [4]. See also Automating unit tests (junit) for Eclipse Plugin development
[1] http://dev.eclipse.org/viewcvs/viewvc.cgi/e4/releng/org.eclipse.e4.builder/scripts/masterBuild.sh?view=co&content-type=text%2Fplain
[2] http://dev.eclipse.org/viewcvs/viewvc.cgi/e4/releng/org.eclipse.e4.builder/builder/general/tests/runtests?view=co
[3] http://dev.eclipse.org/viewcvs/viewvc.cgi/e4/releng/org.eclipse.e4.builder/builder/general/tests/test.xml?view=co&content-type=text%2Fplain
[4] http://www.eclipse.org/articles/Article-PDE-Automation/automation.html

Related

How to build and install an Eclipse plugin using ant

How do I build and install an Eclipse plugin using ant? I want to build a plugin as a zip file and then install the plugin on 32bit or 64bit eclipse. What am I supposed to do here?
Indeed, using PDE/Build to achieve a so-called headless build is difficult, but not impossible.
We are still building our RCP this way.
I recommend reading Paulin's and Sharma's tutorials on the issue.
The Eclipse PDE has its own builder which is built on ant. I'm not sure from your question if you are looking to simply build/export your plugin within eclipse or generate ant build scripts that can be run outside of eclipse. The latter is more difficult. Inside eclipse you can simple go to file -> export -> Plugin-Development -> Deployable plugin and the export wizard will walk you through it, you can select to deploy a zip or exploded directory and then select output location and presto you have your plugin built as a jar that can be dropped into an eclipse instance. If you are looking to use ant outside of eclipse to build you need to go through a series of steps that are complicated to get a 'headless build", if this is what you need to do Google "pde headless" build. I've tried it but gave up. There is also a good book "Building highly modular systems with OSGI/Equinox that has a chapter devoted to this. - Duncan

Test Framework for Eclipse RCP Application

I am new to Eclipse RCP and I'm looking for an open source framework to test my RCP application (especially the GUI). I want to run this tests as unit tests.
Can you suggest some good frameworks with which you made good experiences?
The eclipse platform builds come with an Junit Plug-in test framework that allows JUnit tests written as plugins to run in the context of an Eclipse or RCP app. The JUnit plugin tests could then use SWTBot as well as the standard platform API (open windows, show views, etc).
See http://www.eclipse.org/articles/Article-PDE-Automation/automation.html to get started.
See also Automating unit tests (junit) for Eclipse Plugin development
You may want to try SWTBot. It is made explicitly for the SWT UI. It is in incubation still but under active development.
I had a presentation on EclipseCon '11 about this subject: 10 Techniques to Test a Plug-in.
You coud try WindowTester Pro - this used to be a commercial product, but after Google bought it it open sourced it and now it it is free, it is good actually
http://code.google.com/javadevtools/wintester/html/index.html

Getting a RCP feature to export to a p2 site that supports multiple platforms using Buckminster

I have a simple RCP Plugin (with a product) and I want it to run in atleast Linux and Windows (32 and 64bit). I have a product that contains a Feature from which buckminster uses to create the p2.site. (I only use a build.properties and buckminster.properties files, no *.cspec and *.rmap files, since these probably get generated by buckminster from the RCP product/feature files).
My problem is that my feature has a link to the 64bit linux swt plugin (I'm running 64bit linux) but if I add references to the windows swt plugins to my RCP .product the buckminster build fails to resolve these plugins and then does not export the p2.site correctly.
How do I get buckminster to build the p2 site by looking at the dependencies of my RCP .product file and if it doesn't resolve the win32 or win64 swt libraries from my workspace that it will look else where for these dependencies?
I like the idea of buckminster determining my project dependencies from my .product file so I don't have to keep a .cspec and a .product file in sync, when I make changes to my project's dependencies. If the dependencies are not found on my workspace then I want buckminster to find the missing dependencies (could be all of them if running from Hudson server) from "maybe" a .rmap etc
You have to execute your site.p2 target several times, to provide a build for each platform.
See the tutorial on the Eclipse wiki or on Ralf Ebert's blog about more specific details.

Continuous integration & eclipse plugin development

I am developing a set of eclipse plugins, and I have several JUnit plugin tests that actually start another instance of eclipse, create a mock workspace and a mock project and runs various operations on them. I want to put that on continuous integration and I am at loss as to where to start. I am using Hudson, would there be any plugins that makes that easier? Can those tests launch eclipse in headless mode or something on the CI server? Pointers would be much appreciated.
I think the best solution for building Eclipse-based software currently is Tycho - it is based on Maven and uses your standard Eclipse files (like manifest, target platform, product definition). I got started with it using an intro from this blog: http://mattiasholmqvist.se/2010/02/building-with-tycho-part-1-osgi-bundles/, and it worked really well. We also use Hudson, and since Tycho is Maven-based, Hudson integration was trivial and worked simply by calling Maven, which Hudson supports out of the box.
As far as I know, Buckminster tries to solve these problems: you can create descriptors, and then Buckminster can execute your tasks.
For Hudson there is a Buckminster module, that helps executing the Buckminster builds.
maybe this helps you to avoid plugin tests? ;) i like to avoid them... by using mock objects...
http://blog.srvme.de/2010/12/10/mock-eclipse-ifile/

Eclipse PDT & PHPUnit?

Is there any integration of PHPUnit with Eclipse PDT?
If not, are there any plans to do so?
See Eclipse Plugin PHP Tool Integration (PTI) which provides integration of following features for Eclipse:
PHP_CodeSniffer
PHPUnit
PHP Depend
PHP Copy/Paste Detector
Update sites (Help - Install Software - Add ...):
Latest stable release: http://www.phpsrc.org/eclipse/pti/
Development version: http://www.phpsrc.org/eclipse/pti-dev/
We've developed an Eclipse plugin called MakeGood that integrates PHPUnit and more testing frameworks with Eclipse PDT.
MakeGood is a continuous test runner to run unit tests on Eclipse PDT.
MakeGood provides fast feedback by automated workflows for running tests, tracking failures and errors and fatal errors. This will help developers to do Test Driven Development (TDD) and Continuous Testing.
For more information, visit our website at: https://github.com/piece/makegood/wiki
It is possible to integrate PHPUnit with PDT in a simple way (these settings aren't fully generic but should be a good starting point).
Select the Run > External Tools >
External tools configurations
Create a new program
Set the Location to point to your
executable (/usr/bin/phpunit on
linux)
Set the Working Directory to use the
variable ${workspace_loc}
Set the Arguments to
${resource_path}
Now select Run > External Tools > PHPUnit to execute the selected test file. This simply executes phpunit and sends STDOUT to the Eclipse terminal. Simple but effective.
Subsequently, you can use the icon with a green arrow and red toolbox to run PHPUnit without having to navigate the menus.
Sebastian Bergmann did approach pdt back in 2006... but with no obvious result.
And his latest entries on his blog only mention PHPEdit 2.12 and Zend Studio.
The only testing framework officially documented on the PDT side is the "PDT Testing Framework", and it does not seem actively maintained...
So, no. There does not seem to be any plan to actively integrate PHPUnit in PDT anytime soon.
(disclaimer: I am absolutely not the developer of the project I'm speaking about here; only a user ^^ (And as I don't know JAVA, it would be quite hard for me to help by contributing code... So this is my way of helping :-) ) )
There is currently work in progress on that side : a few weeks ago (maybe no more than two weeks), the first of a project of integrating phpunit in Eclipse has been released:
http://code.google.com/p/phpunit4eclipse/
What it does:
allows to launch phpunit tests from eclipse
and get some "visual clue" of what is going on
which is, in some way, better / more user-friendly than the approach proposed by Sebastian on phpunit's wiki.
For some kind of screenshot, see http://code.google.com/p/phpunit4eclipse/wiki/j2phpUnitWrapper
Unfortunately, it is not (yet?) developed as an Eclipse plugin:
it is a separate JAVA project, that launches phpunit
or something like that, as far as I can tell...
which means :
not as well integrated in Eclipse as it could
most important thing is when you double-click on a test class/method, it doesn't get you to that class/method (because the tests' result are shown by the JAVA project, and the test class/method is in another, PHP, project)
it is still quite hard to install :
I have not successfully managed to install it in Eclipse PDT
I have had to install "Eclipse IDE for Java Developers", and, then, install the PDT plugin in this one (which works fine, but is not "easy")
Anyway, this is work in progress, the project is still quite young, and it's only a first step...
A google group has been created for that project a few time ago: http://groups.google.com/group/phpunit4eclipse-user/
It is currently empty, but I'm sure it would help if some people joined in, gave their thoughts, and why not, helped!
There is defnitely integration for Eclipse PDT and PHPUnit. both PHPSRC and MakeGood
work well though I am a fan of MakeGood for phpunit phpsrc comes with other goodies like CodeSniffer. I have branched a PHPUnit CodeSniffer Standard on github that validates the quality of phpunit tests which I can run with the Eclipse PHP Tools CodeSniffer plugin. This has updates for new phpunit package like setUp and tearDown.
makes sure there is assertions in tests. Something devs like to leave out when trying to meet code coverage metrics
Makes sure there is no more than 1 assertion per test. A best practice
Setting up PDT in Eclipse is not straightforward.
There's a lot of tiny details involved
Here's the high level steps.
1 Windows update
2 Install JRE a. http://www.java.com/en/download/index.jsp
3 Create a folder C:\eclipse\workspace
4 Install eclipse pdt
a. http://www.zend.com/en/downloads/thankyou?package=573
5 Install xampp –win32-1.81-vc9
a. http://sourceforge.net/projects/xampp/files/XAMPP%20Windows/1.8.1/xampp-win32-1.8.1-VC9-installer.exe/download
6 Install pear phpunit
pear clear-cache
pear upgrade pear
pear update-channels
pear upgrade --alldeps -f
pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony-project.com
pear channel-discover components.ez.no
pear install --alldeps phpunit/PHPUnit
7 Install Xdebug plugin
a. http://xdebug.org/files/php_xdebug-2.2.1-5.4-vc9.dll
b. Phpinfo settings for xdebug
[xdebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.1-5.4-vc9.dll"
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_port=9000
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log="C:\xampp\php\logs"
8 Install MakeGood
a. http://eclipse.piece-framework.com/
It took me nearly 3 days to finally get everything right so I put together a video tutorial
Good luck!
There is a plugin on the Eclipse Marketpalce now called PTI PHP Tool Integration.
http://www.phpsrc.org/
I also run PHPUnit as an external tool like DavidWinterbottom proposed.
One thing I also add depending on the type of project is going into Build Options tab and selecting first options after : "run the builder :". This triggers the unit tests to be run every time you save a file. This is great to get a really quick red-green-refactor feedback loop.
I have posted the entire steps with screenshots here : http://nicholaslemay.blogspot.com/2010/02/using-eclipse-phpunit-as-automatic.html
Using phpunit from Ant also is possible, and Ant is natively supported by Eclipse. Simple have a new <exec executable="phpunit"> in a target and voilà, you can use phpunit in eclipse, through ant.
Following #DavidWinterbottom response (Eclipse Indigo):
Select the Run -> External Tools -> External tools configurations
Create a new program
Set the Location to point to your executable (/usr/bin/phpunit on Linux, or path to phpunit.bat on Windows)
Set the Arguments to absolute path to your phpunit folder (C:\phpproject\testunit)
I couldn't make get it to using ${project_loc} or ${project_path}.
For all using composer on unix like machine (eclipse and xdebug installed):
cd <project-root>
ln -s vendor/bin/phpunit phpunit.php
Open eclipse, open run/debug configuration, create a new debug configuration, and select phpunit.php as file to debug. Continue the rest of the setup as usual, set breakpoints, that's it.
You have and integration of PHPUnit on top of PDT in Zend Studio. There is a CE edition too.
I tried PHP Unit in Eclipse and was not happy with the configuration issues. I switched to NetBeans PHP IDE.
I recommend NetBeans PHP IDE for PHP Unit testing.
http://www.netbeans.org/kb/docs/php/phpunit.html