The JUnit framework contains 2 Assert classes (in different packages, obviously) and the methods on each appear to be very similar. Can anybody explain why this is?
The classes I’m referring to are: junit.framework.Assert and org.junit.Assert.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The old method (of JUnit 3) was to mark the test-classes by extending
junit.framework.TestCase. That inheritedjunit.framework.Assertitself and your test class gained the ability to call the assert methods this way.Since version 4 of JUnit, the framework uses
Annotationsfor marking tests. So you no longer need to extendTestCase. But that means, the assert methods aren’t available. But you can make a static import of the newAssertclass. That’s why all the assert methods in the new class are static methods. So you can import it this way:After this static import, you can use this methods without prefix.
At the redesign they also moved to the new package
org.junitthat follows better the normal conventions for package naming.