GeeCON Prague 2014*
The moose likes Java in General and the fly likes AssumptionViolatedException with JUnit but Why and how to Solve? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "AssumptionViolatedException with JUnit but Why and how to Solve?" Watch "AssumptionViolatedException with JUnit but Why and how to Solve?" New topic
Author

AssumptionViolatedException with JUnit but Why and how to Solve?

Gynnad Paullussen
Ranch Hand

Joined: Jan 26, 2011
Posts: 49
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:

Here is the code of my class and test class:
Class that calls to start the Test:

Test class:


I want to start the tests via the CMS system. To ask for the Tests in the CMS system you need to use Velocity code. When I'm asking it I get this error. If I change the method to something where I don't use JUnit it works. But when I want to use JUnit inside it, I get this error.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14194
    
  20

This is the important bit:
java.lang.NoClassDefFoundError: org/junit/internal/AssumptionViolatedException

It says that the class org.junit.internal.AssumptionViolatedException cannot be found.

This is most likely because you are somehow mixing up different versions of JUnit. Maybe you have multiple versions of JUnit on your classpath and they get mixed up. Make sure that you use only one version.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Gynnad Paullussen
Ranch Hand

Joined: Jan 26, 2011
Posts: 49
Jesper de Jong wrote:This is the important bit:
java.lang.NoClassDefFoundError: org/junit/internal/AssumptionViolatedException

It says that the class org.junit.internal.AssumptionViolatedException cannot be found.

This is most likely because you are somehow mixing up different versions of JUnit. Maybe you have multiple versions of JUnit on your classpath and they get mixed up. Make sure that you use only one version.


I think the CMS system has a JUnit file and my plugin has a JUnit file and that is the problem? Or is that not possible?

But I don't know how to solve it..
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14194
    
  20

It's hard to say exactly why you get this without knowing a lot more details of your exact environment.

Maybe you are including a version of JUnit with your own software, while the CMS also has a version of JUnit included? The CMS might then pick up your version of JUnit instead of its own version and gets confused. You'd have to check what version of JUnit the CMS includes and use the same version to compile your own software; at runtime, don't include JUnit with your own software, but let Java pick the one that's included with the CMS.

That's just speculation though, it could also be something completely different.
Gynnad Paullussen
Ranch Hand

Joined: Jan 26, 2011
Posts: 49
Jesper de Jong wrote:It's hard to say exactly why you get this without knowing a lot more details of your exact environment.

Maybe you are including a version of JUnit with your own software, while the CMS also has a version of JUnit included? The CMS might then pick up your version of JUnit instead of its own version and gets confused. You'd have to check what version of JUnit the CMS includes and use the same version to compile your own software; at runtime, don't include JUnit with your own software, but let Java pick the one that's included with the CMS.

That's just speculation though, it could also be something completely different.


Yes the problem was the wrong JUnit class. They conflicted (4.8.2 and 3.8.2) Thanks!
 
GeeCON Prague 2014
 
subject: AssumptionViolatedException with JUnit but Why and how to Solve?