7
7
import io .testomat .core .propertyconfig .impl .PropertyProviderFactoryImpl ;
8
8
import io .testomat .core .propertyconfig .interf .PropertyProvider ;
9
9
import io .testomat .core .runmanager .GlobalRunManager ;
10
+ import io .testomat .testng .filter .TestIdFilter ;
10
11
import io .testomat .testng .methodexporter .TestNgMethodExportManager ;
11
12
import io .testomat .testng .reporter .TestNgTestResultReporter ;
12
13
import java .util .Set ;
13
14
import java .util .concurrent .ConcurrentHashMap ;
14
15
import org .slf4j .Logger ;
15
16
import org .slf4j .LoggerFactory ;
17
+ import org .testng .IInvokedMethod ;
16
18
import org .testng .IInvokedMethodListener ;
17
19
import org .testng .ISuite ;
18
20
import org .testng .ISuiteListener ;
23
25
/**
24
26
* TestNG listener for Testomat.io integration.
25
27
* Reports TestNG test execution results to Testomat.io platform.
26
- * Supports custom annotations (@Title, @TestId) and handles disabled tests.
27
28
* Also exports test method bodies when required.
28
29
*/
29
- public class TestNgListener implements ISuiteListener , ITestListener , IInvokedMethodListener {
30
+ public class TestNgListener implements ISuiteListener , ITestListener ,
31
+ IInvokedMethodListener {
30
32
private static final Logger log = LoggerFactory .getLogger (TestNgListener .class );
31
33
private static final String LISTENING_REQUIRED_PROPERTY_NAME = "testomatio.listening" ;
32
34
@@ -36,6 +38,7 @@ public class TestNgListener implements ISuiteListener, ITestListener, IInvokedMe
36
38
private final PropertyProvider provider ;
37
39
38
40
private final Set <String > processedClasses ;
41
+ private final TestIdFilter testIdFilter ;
39
42
40
43
public TestNgListener () {
41
44
this .methodExportManager = new TestNgMethodExportManager ();
@@ -44,6 +47,7 @@ public TestNgListener() {
44
47
this .reporter = new TestNgTestResultReporter ();
45
48
this .provider =
46
49
PropertyProviderFactoryImpl .getPropertyProviderFactory ().getPropertyProvider ();
50
+ this .testIdFilter = new TestIdFilter ();
47
51
}
48
52
49
53
/**
@@ -58,6 +62,7 @@ public TestNgListener(TestNgMethodExportManager methodExportManager,
58
62
this .methodExportManager = methodExportManager ;
59
63
this .provider = provider ;
60
64
this .processedClasses = ConcurrentHashMap .newKeySet ();
65
+ this .testIdFilter = new TestIdFilter ();
61
66
}
62
67
63
68
@ Override
@@ -117,6 +122,15 @@ public void onTestFailure(ITestResult result) {
117
122
exportTestClassIfNotProcessed (result .getTestClass ().getRealClass ());
118
123
}
119
124
125
+ @ Override
126
+ public void onTestStart (ITestResult result ) {
127
+ if (!isListeningRequired ()) {
128
+ return ;
129
+ }
130
+
131
+ testIdFilter .filterTest (result );
132
+ }
133
+
120
134
@ Override
121
135
public void onTestSkipped (ITestResult result ) {
122
136
if (!isListeningRequired ()) {
@@ -140,6 +154,11 @@ private void exportTestClassIfNotProcessed(Class<?> testClass) {
140
154
}
141
155
}
142
156
157
+ @ Override
158
+ public void afterInvocation (IInvokedMethod method , ITestResult testResult ) {
159
+
160
+ }
161
+
143
162
private boolean isListeningRequired () {
144
163
try {
145
164
return provider .getProperty (LISTENING_REQUIRED_PROPERTY_NAME ) != null ;
0 commit comments