Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AssumptionViolatedException with JUnit but Why and how to Solve?

 
Gynnad Paullussen
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gynnad Paullussen
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic