On 04/08/2013 11:40 AM, Martin Malina wrote:
Hi Mickael,
Today we started testing JBT 4.1.0.Alpha2 and noticed that this is quite a big problem for us. Most of our tests fail with something like this:

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NoSuchMethodError: org.hamcrest.core.IsAnything.any(Ljava/lang/Class;)Lorg/hamcrest/Matcher;)
at org.eclipse.swt.SWT.error(SWT.java:4392)
at org.eclipse.swt.SWT.error(SWT.java:4307)
This is https://bugs.eclipse.org/bugs/show_bug.cgi?id=404346

Right now we don't know how to overcome this in automated jenkins test runs - swtbot always takes the newest version of hamcrest from the kepler platform, so even adding older hamcrest repo wouldn't help here. Do you have any suggestion for us? :)
That's because Kepler M6 ships Junit 4.10 which depends on Hamcrest 1.3. SWTBot builds against Hamcrest 1.1 and Hamcrest has API breaks between 1.1 and 1.3.
The general workaround is to make sure that you test bundle will resilve to Junit < 4.10 and hamcrest 1.1. This can be achieved by setting strict version range in your test bundle MANIFEST for org.junit and org.hamcrest, so Tycho will use the older ones, and test should work.

Also, what will be the fix in SWTBot? If you fix it to work with the new hamcrest, it won't work with the older version, right? So this new swtbot will not be able to work with Juno with older hamcrest then?
Cf bug comments.
The fix consist in using different way to instantiate Matchers. Fortunately, there are still some public constructors that we can use directly and that are available with hamcrest 1.1 and 1.3.

I'm totally opposed to break backward-compatibility in SWTBot. Since you're having trouble because of this bug, I'll try to fix it soon. Any help is welcome.

Cheers,
--
Mickael Istria
Eclipse developer at JBoss, by Red Hat
My blog - My Tweets