【问题标题】:Is there a alternative of @AfterMethod in junit?junit中是否有@AfterMethod的替代方法?
【发布时间】:2015-05-15 19:46:16
【问题描述】:

我无法在 junit 中使用 @AfterMethod,因为它属于 testng。在 junit 中有没有 @AfterMethod 的替代方法。

【问题讨论】:

  • 你试过用谷歌搜索“junit aftermethod”吗? JUnit 等价物的文档是第一个结果。

标签: java junit testng


【解决方案1】:

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

所以直接相当于@AfterMethod 就是@After

@BeforeClass@AfterClass 在全班之前/之后。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-06
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 2010-09-20
    • 2021-08-29
    • 2023-03-14
    • 1970-01-01
    相关资源
    最近更新 更多