Help JUnitMax play with Hamcrest 1.3

I have been working on converting our codebase to JUnit, with a secondary aim of trying out JUnitMax.

I ran the Max and quickly discovered that it failed when trying to execute assertions using the Hamcrest hasItems matcher.

The assertion looks something like:

NoSuchMethodException describeMismatch

This error frequently occurs because JUnit packages an older Version of the org.hamcrest.Matcher class which does not have the describeMismatch method.

I dug around a bit in the plugins directory in the eclipse install folder and found that it contains a junit-4.8.2.jar. Happy days I thought, I can simply do what I’ve been getting used to doing for a while and replace it with junit-dep-4.8.2.jar which does not contain the hamcrest classes.

Unfortunately this didn’t quite work. It turns out that you need to call it exactly the same junit-4.8.2.jar. I thought this was because there’s an entry in the MANIFEST.MF file but I tried to change it and that didn’t work too well.

Renaming the Jar file however works a treat and now I have full JUnitMax action on my box.

I’ve posted on the JUnitMax forums about the problem here.

Share