Hamcrest 1.2 dependency

8 views
Skip to first unread message

Eric Lefevre-Ardant

unread,
Dec 8, 2010, 12:12:17 PM12/8/10
to narrati...@googlegroups.com
Hi everyone,

Just wanted to share that I had the worst time making Hamcrest 1.2 (a dependency for Narrative) work.
The Hamcrest classes of a version older than 1.2 are *included* in the JUnit 4.8.2 jar, at least the junit:junit version that is often declared in Maven POMs. So they tend to take precedence over the one from Hamcrest 1.2.

The solution is to define a dependency with junit:junit-dep instead of junit:junit.

Of course, many other tools define a dependency with junit:junit, so you'll also need lots of quality time with mvn dependency:tree to figure them all. In my case, I had to tune dependencies for Powermock, JUnit and JWebUnit.

I hope this will help someone...

Eric

Douglas Squirrel

unread,
Dec 8, 2010, 12:41:07 PM12/8/10
to narrati...@googlegroups.com

Thanks Eric, and sorry it was painful. Is there anything we could do to help others, besides referring them to your helpful description of what to do?

Eric Lefevre-Ardant

unread,
Dec 8, 2010, 4:35:19 PM12/8/10
to narrati...@googlegroups.com
One option could be to match the version that ships with the latest version of JUnit. Would that make sense?

Douglas Squirrel

unread,
Dec 9, 2010, 2:54:09 AM12/9/10
to narrati...@googlegroups.com

What do other folks think of using the hamcrest from junit? I can't quite manage to figure out exactly which version that is but http://tech.dir.groups.yahoo.com/group/junit/message/22868 seems to be a relevant discussion.

Samir Talwar

unread,
Dec 9, 2010, 10:00:37 AM12/9/10
to narrati...@googlegroups.com
What do most people using JUnit do? Use the version of Hamcrest that comes with it or a newer one? I believe we went with 1.2 because that's what we use.

— Samir.

Eric Lefevre-Ardant

unread,
Dec 9, 2010, 10:36:59 AM12/9/10
to narrati...@googlegroups.com
Difficult to say for me. We generally use FEST in place of Hamcrest.
Reply all
Reply to author
Forward
0 new messages