I'm trying to make Junit tests. I want to start them by asking for a method in the CMS system. Because I'm testing plugins. The problem is that I get this exception and I don't know why. Naah I find that the problem could be that I'm using JUnit 4.8.2, but when I'm running the test in Eclipse everything worked fine. So I can't find the solution. Here is the error:
org.apache.velocity.exception.MethodInvocationException: Invocation of method
'getTest' in class nl.company.cms.three.viewtool.LoginViewTool threw exception
java.lang.NoClassDefFoundError: org/junit/internal/AssumptionViolatedException at
working/2a90929a-3fbf-43e9-9961-4a40279ec907_5c6e0bff-cfeb-44c6-86e2-
a0ba40e7b66c.field[line 1, column 15]
Here is the code of my class and test class: Class that calls to start the Test:
public String getTest(){
Result r = org.junit.runner.JUnitCore.runClasses(MyTestClass.class);
if(r.getRunCount() > 0){
String s = "Failcount = " + r.getFailureCount() + " // " +
r.getRunCount() + " in " + r.getRunTime() + " ms";
System.out.println(r.getFailures().get(0).getTrace());
System.out.println("Runcount: "+r.getRunCount());
System.out.println("Runtime: "+r.getRunTime());
System.out.println("Ignore count: "+r.getIgnoreCount());
System.out.println("Failure count: "+ r.getFailureCount());
return s;
}
else{
return "Something ging kei verkeerd jonge!";
}
}
Test class:
public class MyTestClass {
@Test
public void testMultiply() {
CustomLoginViewTool tester = new CustomLoginViewTool();
assertEquals("Result", 40, tester.multiply(10, 5));
}
@Test
public void testMultiply1() {
CustomLoginViewTool tester = new CustomLoginViewTool();
assertEquals("Result", 50, tester.multiply(10, 5));
}
@Test
public void testMultiply2() {
CustomLoginViewTool tester = new CustomLoginViewTool();
assertEquals("Result", "ASDF", tester.multiply(10, 5));
}
@Test
public void testMultiply3() {
CustomLoginViewTool tester = new CustomLoginViewTool();
assertEquals("Result", 50, tester.multiply(10, 5));
}
@Test
public void testMultiply4() {
CustomLoginViewTool tester = new CustomLoginViewTool();
assertEquals("Result", 47, tester.multiply(10, 5));
}
@Test
public void testMultiply5() {
CustomLoginViewTool tester = new CustomLoginViewTool();
assertEquals("Result", 50, tester.multiply(10, 5));
}
}