TestNg IReporter listener - test start and end time

时间:2015-07-28 23:13:31

标签: listener testng

I am using a sample listener from. http://relevantcodes.com/testng-listener-using-extentreports/

Does someone know how to get the time test was started and end from the listener?

I checked. https://github.com/cbeust/testng/blob/master/src/main/java/org/testng/reporters/SuiteHTMLReporter.java#L424 but its not clear how time info is pulled from. The code does

iim.getDate()

But I don't understand how that provides the diff because it just subtracts diff from itself only.

1 个答案:

答案 0 :(得分:1)

KARTHIK

我已更新帖子,您可以使用新代码检索开始和结束时间:

test.getTest().startedTime = new Date(result.getStartMillis());
test.getTest().endedTime = new Date(result.getEndMillis());

在TestNG中,您可以检索开始和结束的毫秒数,可以将其转换为Date