Skip to content

Commit d2040e0

Browse files
committed
Sometimes test start in one thread and finished in another
1 parent 05c9e97 commit d2040e0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

jdi-light-html-tests/src/test/java/io/github/epam/testng/TestNGListener.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* Email: [email protected]; Skype: roman.iovlev
66
*/
77

8-
import com.jdiai.tools.Safe;
98
import org.testng.IInvokedMethod;
109
import org.testng.IInvokedMethodListener;
1110
import org.testng.ITestNGMethod;
@@ -22,7 +21,7 @@
2221
import static java.lang.System.currentTimeMillis;
2322

2423
public class TestNGListener implements IInvokedMethodListener {
25-
private Safe<Long> start = new Safe<>(0L);
24+
private Long start = currentTimeMillis();
2625

2726
@Override
2827
public void beforeInvocation(IInvokedMethod m, ITestResult tr) {
@@ -32,7 +31,7 @@ public void beforeInvocation(IInvokedMethod m, ITestResult tr) {
3231
String testName = last(testMethod.getTestClass().getName().split("\\.")) +
3332
"." + testMethod.getMethodName();
3433
TEST_NAME.set(testName);
35-
start.set(currentTimeMillis());
34+
start = currentTimeMillis();
3635
logger.step("== Test '%s' START ==", testName);
3736
}
3837
}
@@ -44,7 +43,7 @@ public void afterInvocation(IInvokedMethod method, ITestResult tr) {
4443
String result = getTestResult(tr);
4544
logger.step("=== Test '%s' %s [%s] ===", TEST_NAME.get(), result,
4645
new SimpleDateFormat("mm:ss.SS")
47-
.format(new Date(currentTimeMillis() - start.get())));
46+
.format(new Date(currentTimeMillis() - start)));
4847
if ("FAILED".equals(result)) {
4948
try {
5049
screenshotStep("On Fail Screenshot");

0 commit comments

Comments
 (0)