JUnit 3 是否有类似于 @Ignore 的东西
我被迫使用 JUnit 3。如果我使用 JUnit 4,我偶尔会使用 @Ignore
因为我的一些测试需要一些时间。
JUnit 4 中有类似的东西吗?注释掉测试很草率,更改名称(来自 testXxx()
)可能会导致忘记测试。 @Ignore
很棒,因为它总是提醒您哪些测试没有运行。
有谁有在 JUnit 3 中运行某些测试类方法的最佳实践吗?
I'm forced to use JUnit 3. If I were using JUnit 4, I would occasionally use @Ignore
since several of my tests take a bit of time.
Is there anything analogous in JUnit 4? Commenting out tests is sloppy, and changing the name (from testXxx()
) could lead to forgotten tests. @Ignore
is great, because it always reminds you which tests were not run.
Does anyone have a best practice for running some of a test classes methods in JUnit 3?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除了注释掉测试或重命名它们之外,我不知道任何其他解决方案。我会选择重命名选项并使用我自己的约定。例如,它们都以ignoreXXX()开头。然后您可以使用编辑器进行一次查找/替换,然后您就准备好了。
I don't know any other solution apart from commenting out tests or renaming them. I would go for the renaming option and use my own convention. For example all of them will start with ignoreXXX(). Then you can do one find/replace with your editor and you are ready.
为了有条件忽略Robotium / JUnit 3中的测试,我重写了
runTest()
,这样被忽略的测试将在Eclipse中显示为“成功”,但作为JUnit 3 没有“忽略”状态,这是我能得到的最好的状态。
In order to conditionally ignore tests in Robotium / JUnit 3, I override
runTest()
likeTests which are ignored this way will show up as "Success" in Eclipse, but as there is no "Ignored" state with JUnit 3, this is the best I was able to get.
您可以在该方法前面加上failure,因此所有像failingtest***()这样的方法都将在junit运行期间被忽略。
you can prepend the method with failing, so all methods like failingtest***() will be ignored during the junit run.