I am trying to run my first test with junit on a Spring Web Flow Project from within Eclipse and also from the console with mvn test and but give me the same error.
I had to upgrade my version of spring-test and junit both to the most updated versions and bang everything is working great!
This is a shot in the dark - but I found this on spring's forum. It is consistent with your configuration - you are using Spring-test v2.5 and Junit 4.7, it looks like spring-test v2.5 might only support Junit v4.4.
Try to downgrade to JUnit 4.4 or upgrade to spring-test v2.5.6 and see if the problem goes away.
I found that spring-test 2.5.x expects the org.junit.Assume to contain AssumptionViolatedException, but in junit 4.10 it has been moved to the org.junit.internal package. The tests will stop running (not fail) with ClassNotFoundException.
My workaround was to add my own JUnit Assume copy based on 4.10 and add the AssumptionViolatedException (from internal). This local copy must be added to the classpath first is your IDE and build tool.
public class Assume {
/*
* Ported this from JUnit 4.4 to satisfy spring-test
*/
public static class AssumptionViolatedException extends org.junit.internal.AssumptionViolatedException {
private static final long serialVersionUID = 1L;
public AssumptionViolatedException(Object value, Matcher<?> matcher) {
super(value, matcher);
}
}
// rest of Assume from JUint 4.10 ....
}
The disadvantage is that this class will obviously get stale quickly and future users of the code may not know it exists; it's a future failure waiting to happen.
Also it might not get loaded first. To mitigate this I added tests that check the Assume is loaded first and warn if not:
import java.net.URL;
public class JUnitSpringTestAssumeOverrideCompatibilityChecker {
public static void checkAssumeOverridden() {
URL url = Thread.currentThread().getContextClassLoader().getResource("org/junit/Assume.class");
if (!"file".equals(url.getProtocol())) {
throw new RuntimeException("Expect local override (1st on classpath) of JUnit 4.10 Assume for spring-test 2.5 compatibility");
}
}
}
I have to keep Spring v2.5, downgrading to JUnit 4.4 resolves the problem.
Moreover, you'll see original cause hidden by Assume$AssumptionViolatedException ;)
FYI, Moving to latest spring-test 2.5.6 won't change anything.
Linked SO : Junit4 + Spring 2.5 : Asserts throw "NoClassDefFoundError"