Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » junit4 headless doesn't seem to work with CDT master zip plugin
junit4 headless doesn't seem to work with CDT master zip plugin [message #530507] Thu, 29 April 2010 20:46 Go to next message
Jeff Johnston is currently offline Jeff JohnstonFriend
Messages: 177
Registered: July 2009
Senior Member
I found that junit4 headless from 2.0.0.536 does not work if the ant optional junit 3 plugin from the CDT is around.

org.eclipse.ant.optional.junit_3.2.200.jar

The optional plugin gets dragged in by installing the CDT 6.0.2 master zip plugins. My plugin requires the CDT to run so I download the CDT master zip, unzip it, and copy all the plugins into my eclipse/plugins directory.

I did a: rm -rf org.eclipse.ant.optional.junit_3* in my eclipse/plugins directory and then things started working fine after that.

If the plugin is around, swtbot fails with a class cast exception but no information regarding why (usually there is a "missing" or "can't find" message of some sort). Not sure why it fails under swtbot this way, but if anybody is experiencing this issue and has confirmed that all their plugins are indeed resolved by Eclipse, this may be the cause.
Re: junit4 headless doesn't seem to work with CDT master zip plugin [message #530511 is a reply to message #530507] Thu, 29 April 2010 21:15 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Jeff Johnston wrote:
> I found that junit4 headless from 2.0.0.536 does not work if the ant
> optional junit 3 plugin from the CDT is around.
> org.eclipse.ant.optional.junit_3.2.200.jar
>
> The optional plugin gets dragged in by installing the CDT 6.0.2 master
> zip plugins. My plugin requires the CDT to run so I download the CDT
> master zip, unzip it, and copy all the plugins into my eclipse/plugins
> directory.
>
> I did a: rm -rf org.eclipse.ant.optional.junit_3* in my eclipse/plugins
> directory and then things started working fine after that.
>
> If the plugin is around, swtbot fails with a class cast exception but no
> information regarding why (usually there is a "missing" or "can't find"
> message of some sort). Not sure why it fails under swtbot this way, but
> if anybody is experiencing this issue and has confirmed that all their
> plugins are indeed resolved by Eclipse, this may be the cause.
>

This is a known issue. You can't have both junit4 and junit3 running at
the same time, since junit4 has the same packages as junit3 (for
backward compatibility) but the classes information are different.

I think that's because SWTBot uses a TestListener that is defined in the
common packages, the osgi runtime resolve it from the junit3 bundle but
SWTBot runtime requires the junit4 bundle, hence the ClassCastException.

--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: junit4 headless doesn't seem to work with CDT master zip plugin [message #530535 is a reply to message #530507] Fri, 30 April 2010 02:03 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
To run the <junit /> task from within ant, you'd normally copy the
junit.jar into ant's lib dir[1].

In the world of OSGi, you'd do the same using fragments.

org.eclipse.ant.optional.junit and org.eclipse.swtbot.ant.optional* are
fragments that enhance the ant classpath to add junit to it's classpath.

Adding both junit3 and junit4 to the classpath cause the test runner and
ant to load classes from two different plugins causing the
ClassCastException.

I'm no OSGi expert and don't know if and how to detect multiple
fragments contributing to ant to throw any meaningful warnings. It'd
help if you have any ideas on how to do detect this.

The cheap alternative that swtbot chooses is that the library.xml
shipped in swtbot's ant.optional plugins detect duplicates between
swtbot's ant.optional plugins and warn the user of this case. I should
enhance the build script to emit warnings for checking dups with
eclipse's ant.optional fragment.

--
Ketan
http://ketan.padegaonkar.name | http://eclipse.org/swtbot

[1] - http://ant.apache.org/manual/OptionalTasks/junit.html

On 4/29/10 1:46 PM, Jeff Johnston wrote:
> I found that junit4 headless from 2.0.0.536 does not work if the ant
> optional junit 3 plugin from the CDT is around.
> org.eclipse.ant.optional.junit_3.2.200.jar
>
> The optional plugin gets dragged in by installing the CDT 6.0.2 master
> zip plugins. My plugin requires the CDT to run so I download the CDT
> master zip, unzip it, and copy all the plugins into my eclipse/plugins
> directory.
>
> I did a: rm -rf org.eclipse.ant.optional.junit_3* in my eclipse/plugins
> directory and then things started working fine after that.
>
> If the plugin is around, swtbot fails with a class cast exception but no
> information regarding why (usually there is a "missing" or "can't find"
> message of some sort). Not sure why it fails under swtbot this way, but
> if anybody is experiencing this issue and has confirmed that all their
> plugins are indeed resolved by Eclipse, this may be the cause.
>
Re: junit4 headless doesn't seem to work with CDT master zip plugin [message #530567 is a reply to message #530535] Fri, 30 April 2010 08:01 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 771
Registered: July 2009
Location: Grenoble, France
Senior Member
Hi all,

The easiest way to solve this issue would be that SWTBot have a dependency to bundle org.junit with bundle-version set to 4.0.0 or more. This dependency, along with the "mock" org.junit4 bundle, should be shipped with SWTBot test runner in the zip and in the update-site, so that installing SWTBot would automatically solve this JUnit issue.
Please also note that the JUnit conflict should be resolved for the whole Eclipse platform in the Helios release.

More details: http://wiki.eclipse.org/Eclipse/Testing/JUnit4_Changes and some advices to automate your test build and execution here http://www.bonitasoft.org/blog/eclipse/swtbot-my-new-friend/

Regardsm
--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
Re: junit4 headless doesn't seem to work with CDT master zip plugin [message #530690 is a reply to message #530567] Fri, 30 April 2010 14:24 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
This is good news to hear. I just verified all SWTBot bundles and unless
I've missed something, all of them depend on junit4 :)

So if I understand you correctly, all I need to do is put the junit4
bundles on the update site ?

I'm still unclear how this would solve the issue of telling the user
that there is something else, namely the org.eclipse.ant.optional.junit
bundle from elsewhere that is messing up the classpath.

--
Ketan
http://ketan.padegaonkar.name | http://eclipse.org/swtbot

On 4/30/10 1:01 AM, Mickael Istria wrote:
> Hi all,
>
> The easiest way to solve this issue would be that SWTBot have a
> dependency to bundle org.junit with bundle-version set to 4.0.0 or more.
> This dependency, along with the "mock" org.junit4 bundle, should be
> shipped with SWTBot test runner in the zip and in the update-site, so
> that installing SWTBot would automatically solve this JUnit issue.
> Please also note that the JUnit conflict should be resolved for the
> whole Eclipse platform in the Helios release.
>
> More details: http://wiki.eclipse.org/Eclipse/Testing/JUnit4_Changes and
> some advices to automate your test build and execution here
> http://www.bonitasoft.org/blog/eclipse/swtbot-my-new-friend/
>
> Regardsm
> --
> Mickael Istria - BonitaSoft S.A.
> http://www.bonitasoft.com/products/downloads.php
Re: junit4 headless doesn't seem to work with CDT master zip plugin [message #530701 is a reply to message #530690] Fri, 30 April 2010 14:51 Go to previous message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 771
Registered: July 2009
Location: Grenoble, France
Senior Member
Hi,

Ketan Padegaonkar a écrit :
> So if I understand you correctly, all I need to do is put the junit4
> bundles on the update site ?

The org.junit4 bundle should disappear and is an example of a bad OSGi bundle ;) To conform to the new junit bundle, you should:
* replace all require-bundle: org.junit4 by require-bungle: org.junit;version=4.0.0
* Add the org.junit 4.8.x bundle (available on Orbit) to the SWTBot update-site (may require a CQ for this new version, since Orbit does not ship junit 4.5)
By the way, if you do that, you can safely remove your swtbot.ant.optional bundlea and use the one maintained by the platform team (available at http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ant.opt ional.junit/

And everything should be fine.

HTH,
--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
Previous Topic:SWTBot cheat sheet
Next Topic:Using SWT Bot with GMF - GEF
Goto Forum:
  


Current Time: Sat Dec 20 08:05:02 GMT 2014

Powered by FUDForum. Page generated in 0.01843 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software