注释记录Junit5中每个测试用例的执行时间

Anupama Boorlagadda

我需要记录每个测试用例的执行时间。我不想使用自定义实现。我想知道在junit5

Btw中是否有对此可用的注释,我知道Stopwatch还是Junit4 @Timeout

Anupama Boorlagadda

浏览junit5文档后,我发现了这个示例TimeExtension

此摘录来自他们的文档:

@ExtendWith(TimingExtension.class)
class TimingExtensionTests {

  @Test
  void sleep20ms() throws Exception {
     Thread.sleep(20);
  }

  @Test
  void sleep50ms() throws Exception {
    Thread.sleep(50);
  }

}

编辑:TimingExtension的源代码

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章