13

Whenever I use a Junit assert in my code, my IDE (Intellij IDEA 12) politely offers to static-import it for me:

import static junit.framework.Assert.assertTrue; 

However, it always gives me the choice of importing either the "org.junit" version or the "junit.framework" version:

import static org.junit.Assert.assertTrue; 

I can't find a clear answer online about what the difference is between these two packages - is there a difference? If so, what is it? They both come out of exactly the same Junit4 jar, so what's going on?

3
  • You can always download the source jar as well and debug into the method code (assertTrue) to find out which package it is using. Commented Sep 27, 2013 at 17:59
  • Or just hover over the method on the editor! Commented Sep 27, 2013 at 18:05
  • possible duplicate of differences between 2 JUnit Assert classes Commented Sep 28, 2013 at 7:08

1 Answer 1

15

org.junit.* is JUnit 4+. The other is previous versions.

There's backwards compatibility, so junit.framework.* is included in junit-4.x.jar.

Sign up to request clarification or add additional context in comments.

6 Comments

So which should be used?
@Edmund If you have access to the newer version, obviously that one.
Why are they both still in the same jar file 4.9?
@powder366 As mentioned in the second paragraph, for backwards compatibility. You can now add the new jar and start using new features, while the old ones still work.
OK. I think they should remove it. Provide a jar for the old library (or the other way around). Now it's to easy to pick the wrong...
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.