Hamcrest conflict in jUnit.
2 minutes read

Using jUnit 4.8 i got into an issue when testing the few lambda expressions. I was constantly getting this error while testing code involving Hamcrest matchers.

java.lang.NoSuchMethodError: org.hamcrest.core.AllOf.allOf(Lorg/hamcrest/Matcher;Lorg/hamcrest/Matcher;)Lorg/hamcrest/Matcher;

However when i ran the application it was all fine. So i could sense the issue with the jUnit.

The problem is due to hamcrest versioning issue with jUnit. jUnit uses an old version while other libraries (in my case LambdaJ) was using the latest version. The fix will be to download the junit-dep-4.*.jar from the jUnit download page. Since you app already have Hamcrest class the test will run smoothly.

Prasanna is a full stack web developer, with exposure to various programming languages. Uses mostly Java, Javascript these days and got ~13 years of architecting and coding enterprise software solutions.