java – Eclipse JUnit – possible causes of seeing initializationError in Eclipse window

java – Eclipse JUnit – possible causes of seeing initializationError in Eclipse window

Youve probably got one of two problems:

n

1) Youre using JUnit 4.11, which doesnt include hamcrest. Add the hamcrest 1.3 library to your classpath.

n

2) Youve got hamcrest 1.3 on your classpath, but youve got another version of either junit or hamcrest on your classpath.

n

For background, junit pre 4.11 included a cut down version of hamcrest 1.1. 4.11 removed these classes.

For me it was a silly mistake. I inadvertently set the test as private instead of public:

n

@Testnprivate void thisTestWasCausingProblems() {n...n}n

n

it should have been

n

@Testnpublic void thisTestIsOK() {n...n}n

java – Eclipse JUnit – possible causes of seeing initializationError in Eclipse window

Just try Project > Clean… – seems to be THE solution to many problems in Eclipse!

Leave a Reply

Your email address will not be published.