Eclipse JUnit - possible causes of seeing "initializationError" in Eclipse window
You've probably got one of two problems:
1) You're using JUnit 4.11, which doesn't include hamcrest. Add the hamcrest 1.3 library to your classpath.
2) You've got hamcrest 1.3 on your classpath, but you've got another version of either junit or hamcrest on your classpath.
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:
@Test
private void thisTestWasCausingProblems() {
...
}
it should have been
@Test
public void thisTestIsOK() {
...
}
Just try "Project > Clean..." - seems to be THE solution to many problems in Eclipse!
For me it was a missing static
keyword in one of the JUnit annotated methods, e.g.:
@AfterClass
public static void cleanUp() {
// ...
}
I received this error when the class was annotated with @Ignore and I tried to run a specific test via right clicking on it. Removing the @Ignore fixed the problem.