7
7
8
8
import java .lang .reflect .InvocationTargetException ;
9
9
import java .lang .reflect .Method ;
10
+ import java .util .ArrayList ;
10
11
import java .util .Collection ;
11
12
import java .util .Collections ;
12
13
import java .util .Iterator ;
16
17
import java .util .Optional ;
17
18
import java .util .Set ;
18
19
import java .util .concurrent .atomic .AtomicInteger ;
20
+ import java .util .function .Consumer ;
19
21
import java .util .stream .Collectors ;
20
22
import org .testng .DataProviderHolder ;
21
23
import org .testng .DataProviderInvocationException ;
37
39
import org .testng .SuiteRunner ;
38
40
import org .testng .TestException ;
39
41
import org .testng .TestNGException ;
42
+ import org .testng .collections .CollectionUtils ;
40
43
import org .testng .collections .Lists ;
41
44
import org .testng .collections .Maps ;
42
45
import org .testng .collections .Sets ;
@@ -104,12 +107,48 @@ public List<ITestResult> invokeTestMethods(
104
107
//
105
108
// Not okToProceed. Test is being skipped
106
109
//
107
- ITestResult result =
108
- registerSkippedTestResult (
109
- testMethod , System .currentTimeMillis (), new Throwable (okToProceed ));
110
- m_notifier .addSkippedTest (testMethod , result );
111
- InvokedMethod invokedMethod = new InvokedMethod (System .currentTimeMillis (), result );
112
- invokeListenersForSkippedTestResult (result , invokedMethod );
110
+ List <ITestResult > results = new ArrayList <>();
111
+ Consumer <ITestResult > resultProcessor =
112
+ result -> {
113
+ m_notifier .addSkippedTest (testMethod , result );
114
+ InvokedMethod invokedMethod = new InvokedMethod (System .currentTimeMillis (), result );
115
+ invokeListenersForSkippedTestResult (result , invokedMethod );
116
+ };
117
+ boolean reportAllDataDrivenTestsAsSkipped =
118
+ m_configuration .getReportAllDataDrivenTestsAsSkipped ();
119
+ if (reportAllDataDrivenTestsAsSkipped && testMethod .isDataDriven ()) {
120
+ ParameterHandler handler =
121
+ new ParameterHandler (
122
+ m_configuration .getObjectFactory (),
123
+ annotationFinder (),
124
+ buildDataProviderHolder (),
125
+ 1 );
126
+
127
+ ParameterBag bag =
128
+ handler .createParameters (
129
+ testMethod , Maps .newHashMap (), Maps .newHashMap (), context , instance );
130
+ Iterator <Object []> allParamValues = Objects .requireNonNull (bag .parameterHolder ).parameters ;
131
+ Iterable <Object []> allParameterValues = CollectionUtils .asIterable (allParamValues );
132
+ for (Object [] next : allParameterValues ) {
133
+ if (next == null ) {
134
+ continue ;
135
+ }
136
+ Method m = testMethod .getConstructorOrMethod ().getMethod ();
137
+ Object [] parameterValues = Parameters .injectParameters (next , m , context );
138
+ ITestResult result =
139
+ registerSkippedTestResult (
140
+ testMethod , System .currentTimeMillis (), new Throwable (okToProceed ));
141
+ result .setParameters (parameterValues );
142
+ resultProcessor .accept (result );
143
+ results .add (result );
144
+ }
145
+ } else {
146
+ ITestResult result =
147
+ registerSkippedTestResult (
148
+ testMethod , System .currentTimeMillis (), new Throwable (okToProceed ));
149
+ resultProcessor .accept (result );
150
+ results .add (result );
151
+ }
113
152
testMethod .incrementCurrentInvocationCount ();
114
153
GroupConfigMethodArguments args =
115
154
new Builder ()
@@ -119,7 +158,7 @@ public List<ITestResult> invokeTestMethods(
119
158
.withParameters (parameters )
120
159
.build ();
121
160
this .invoker .invokeAfterGroupsConfigurations (args );
122
- return Collections .singletonList ( result );
161
+ return Collections .unmodifiableList ( results );
123
162
}
124
163
125
164
// For invocationCount > 1 and threadPoolSize > 1 run this method in its own pool thread.
0 commit comments