“junit.framework中的断言已被弃用” - 接下来要使用什么?

问题描述 投票:109回答:4

我将junit版本改为4.11并得到:

[WARNING] [deprecation] Assert in junit.framework has been deprecated
[WARNING] [deprecation] Assert in junit.framework has been deprecated
....

如何迁移?

junit junit4
4个回答
201
投票

因为看起来Assert类已经从Qazxswpoi移到了JUnit 4.0中的junit.framework - 你可以使用它,而不是弃用它。


75
投票

从中更改您的import语句

org.junit.Assert

import junit.framework.Assert;

这将纠正您的JUnit弃用警告。


5
投票

仅供参考:您可以在apiwave(import org.junit.Assert; )上自动检查,并查看junit.framework.Assert的替换是org.junit.Assert


1
投票

我们进行了大量的测试并且有很多断言。

添加类似的东西

http://apiwave.com/java/api/junit.framework.Assert

对import语句也有助于限制测试代码的变化。

© www.soinside.com 2019 - 2024. All rights reserved.