views:

638

answers:

2

Is there a recommended way to integrate Hamcrest into the JUnit configuration in Eclipse? Currently Eclipse's JUnit comes with Hamcrest-core only. I want to edit that configuration to include Hamcrest-all. How should I do this?

+2  A: 

There's nothing to stop you adding hamcrest as a JAR to your eclipse project's build path. If there's one packaged with eclipse (and I didn't realise there was, but fair enough), then it's just there as a convenience.

skaffman
Yes, I could always add it as a library, but I was hoping to find a way to embed it into JUnit's configuration, so that it's automatically added to all (existing and new) projects that use JUnit.
Hosam Aly
A: 

JUnit goes in two distributions: with Hamcrest (junit-4.6.jar) and without Hamcrest (junit-dep-4.6.jar). If I understand your question correctly, you need to specify junit-4.6.jar in JUnit configuration. I think it is possible in Eclipse (I use another IDE).

Rorick
It seems to me that JUnit only includes hamcrest-core, while I am trying to integrate hamcrest-all into Eclipse.
Hosam Aly
You're right. Probably you can build your own junit.jar with embedded classes from hamcrest-all.jar and replace junit.jar in JUnit eclipse plugin with it. I'm not sure it is a good idea, but you can try.
Rorick
Yes, I believe this would work, but I don't think it's the "recommended" way of doing it. :)
Hosam Aly