junit.framework.Assert 与org.junit.Assert

differences between 2 JUnit Assert classes

The old method (of Junit 3) was to mark the test-classes by extending junit.framework.TestCase. That inherited junit.framework.Assert itself and your test-class gained the ability to call the assert-methods this way.

Since version 4 of junit the framework uses Annotations for marking tests. So you no longer need to extend TestCase. But that means, the assert-methods aren’t available. But you can make a static import of the new Assert-class. That’s why all the assert-methods in the new class are static methods. So you can import it this way:

Junit相关文章:

全面认识JUnit4.0

posted @ 2018-06-15 14:18  XueXueLai  阅读(776)  评论(0编辑  收藏  举报