junit中有@AfterMethod的替代方法吗? [英] Is there a alternative of @AfterMethod in junit?

查看:112
本文介绍了junit中有@AfterMethod的替代方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在junit中使用@AfterMethod,因为它属于testng.在junit中是否还有@AfterMethod的替代选择.

I am unable to use @AfterMethod in junit as it belongs to testng.Is there any alternative for @AfterMethod in junit.

推荐答案

JUnit 4使用 @Before @After 表示方法需要在单元测试之前或之后运行,这实际上是一种方法.

JUnit 4 uses @Before and @After to indicate methods that need to be run before or after unit tests, which is effectively a method.

所以与@AfterMethod的直接等效项只是@After.

So the direct equivalent to @AfterMethod is just @After.

@BeforeClass

@BeforeClass and @AfterClass are before/after the whole class.

这篇关于junit中有@AfterMethod的替代方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆