-
Notifications
You must be signed in to change notification settings - Fork 1k
/
MyConfigurationListener.java
35 lines (27 loc) · 1.04 KB
/
MyConfigurationListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package test.listeners.github1296;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import org.testng.IConfigurationListener;
import org.testng.ITestResult;
public class MyConfigurationListener implements IConfigurationListener {
private static final Map<String, AtomicInteger> CALLS = new ConcurrentHashMap<>();
public MyConfigurationListener() {
CALLS.clear();
}
public static Map<String, Integer> getCalls() {
return CALLS.entrySet().stream()
.collect(Collectors.toMap(Entry::getKey, each -> each.getValue().get()));
}
@Override
public void onConfigurationSuccess(ITestResult itr) {
String xmlTestName = itr.getTestContext().getCurrentXmlTest().getName();
CALLS.computeIfAbsent(xmlTestName, k -> new AtomicInteger()).incrementAndGet();
}
@Override
public void onConfigurationFailure(ITestResult iTestResult) {}
@Override
public void onConfigurationSkip(ITestResult itr) {}
}