如何在junit测试中执行部分执行时间

时间:2013-11-11 06:30:31

标签: java junit

我想知道在我的测试中执行不同部分的次数,例如

@Test
public void HappyPathTest() {

        connectToServiceRemote();
        // take execution time of connectToServiceRemote();
        getData();
        // take execution time of getData()
        transformData();
        // take execution time of transformData()

}

我目前所做的是使用丑陋的System.currentTimeMillis()并将结果打印到标准输出。

我的问题是:

  • 在junit框架中有一些东西比使用System.currentTimeMillis()更好。
  • 如果没有,我如何在junit的结果报告中包含使用System.currentTimeMillis()计算的信息。

1 个答案:

答案 0 :(得分:1)