65
65
import org .junit .platform .suite .api .SelectUris ;
66
66
67
67
/**
68
+ * The {@code SuiteLauncherDiscoveryRequestBuilder} provides a builder for constructing instances
69
+ * of {@link LauncherDiscoveryRequest} specifically tailored for suite execution.
70
+ *
71
+ * <h2>Example</h2>
72
+ *
73
+ * <pre>{@code
74
+ * SuiteLauncherDiscoveryRequestBuilder.request()
75
+ * .selectors(
76
+ * selectPackage("org.example.user"),
77
+ * selectClass("org.example.payment.PaymentTests"),
78
+ * selectClass(File.class),
79
+ * selectMethod("org.example.order.OrderTests#test1"),
80
+ * selectMethod("org.example.order.OrderTests#test2()"),
81
+ * selectMethod("org.example.order.OrderTests#test3(java.lang.String)"),
82
+ * selectMethod("org.example.order.OrderTests", "test4"),
83
+ * selectMethod(OrderTests.class, "test5"),
84
+ * selectMethod(OrderTests.class, testMethod),
85
+ * selectClasspathRoots(Collections.singleton(Paths.get("/my/local/path1"))),
86
+ * selectUniqueId("unique-id-1"),
87
+ * selectUniqueId("unique-id-2")
88
+ * )
89
+ * .filters(
90
+ * includeEngines("junit-jupiter", "spek"),
91
+ * // excludeEngines("junit-vintage"),
92
+ * includeTags("fast"),
93
+ * // excludeTags("slow"),
94
+ * includeClassNamePatterns(".*Test[s]?")
95
+ * // includeClassNamePatterns("org\.example\.tests.*")
96
+ * )
97
+ * .configurationParameter("key", "value")
98
+ * .enableImplicitConfigurationParameters(true)
99
+ * .suite(File.class)
100
+ * .build();
101
+ * }</pre>
102
+ *
68
103
* @since 1.8
104
+ * @see org.junit.platform.engine.discovery.DiscoverySelectors
105
+ * @see org.junit.platform.engine.discovery.ClassNameFilter
106
+ * @see org.junit.platform.launcher.EngineFilter
107
+ * @see org.junit.platform.launcher.TagFilter
69
108
*/
70
109
@ API (status = Status .INTERNAL , since = "1.8" , consumers = { "org.junit.platform.suite.engine" ,
71
110
"org.junit.platform.runner" })
@@ -81,52 +120,146 @@ public final class SuiteLauncherDiscoveryRequestBuilder {
81
120
private SuiteLauncherDiscoveryRequestBuilder () {
82
121
}
83
122
123
+ /**
124
+ * Creates a mew instance of {@code SuiteLauncherDiscoveryRequestBuilder}
125
+ *
126
+ * @return a new builder
127
+ */
84
128
public static SuiteLauncherDiscoveryRequestBuilder request () {
85
129
return new SuiteLauncherDiscoveryRequestBuilder ();
86
130
}
87
131
132
+ /**
133
+ * Specifies whether to filter standard class name patterns.
134
+ * <p>If set to {@code true}, standard class name patterns are filtered.
135
+ *
136
+ * @param filterStandardClassNamePatterns {@code true} to filter standard class name patterns,
137
+ * {@code false} otherwise
138
+ * @return this builder for method chaining
139
+ */
88
140
public SuiteLauncherDiscoveryRequestBuilder filterStandardClassNamePatterns (
89
141
boolean filterStandardClassNamePatterns ) {
90
142
this .filterStandardClassNamePatterns = filterStandardClassNamePatterns ;
91
143
return this ;
92
144
}
93
145
146
+ /**
147
+ * Add all the supplied {@code selectors} to the request.
148
+ *
149
+ * @param selectors the {@code DiscoverySelectors} to add; never {@code null}
150
+ * @return this builder for method chaining
151
+ */
94
152
public SuiteLauncherDiscoveryRequestBuilder selectors (DiscoverySelector ... selectors ) {
95
153
delegate .selectors (selectors );
96
154
return this ;
97
155
}
98
156
157
+ /**
158
+ * Add all the supplied {@code selectors} to the request.
159
+ *
160
+ * @param selectors the {@code DiscoverySelectors} to add; never {@code null}
161
+ * @return this builder for method chaining
162
+ */
99
163
public SuiteLauncherDiscoveryRequestBuilder selectors (List <? extends DiscoverySelector > selectors ) {
100
164
delegate .selectors (selectors );
101
165
return this ;
102
166
}
103
167
168
+ /**
169
+ * Add all the supplied {@code filters} to the request.
170
+ *
171
+ * <p>The {@code filters} are combined using AND semantics, i.e. all of them
172
+ * have to include a resource for it to end up in the test plan.
173
+ *
174
+ * <p><strong>Warning</strong>: be cautious when registering multiple competing
175
+ * {@link EngineFilter#includeEngines include} {@code EngineFilters} or multiple
176
+ * competing {@link EngineFilter#excludeEngines exclude} {@code EngineFilters}
177
+ * for the same discovery request since doing so will likely lead to
178
+ * undesirable results (i.e., zero engines being active).
179
+ *
180
+ * @param filters the {@code Filter}s to add; never {@code null}
181
+ * @return this builder for method chaining
182
+ */
104
183
public SuiteLauncherDiscoveryRequestBuilder filters (Filter <?>... filters ) {
105
184
delegate .filters (filters );
106
185
return this ;
107
186
}
108
187
188
+ /**
189
+ * Add the supplied <em>configuration parameter</em> to the request.
190
+ *
191
+ * @param key the configuration parameter key under which to store the
192
+ * value; never {@code null} or blank
193
+ * @param value the value to store
194
+ * @return this builder for method chaining
195
+ */
109
196
public SuiteLauncherDiscoveryRequestBuilder configurationParameter (String key , String value ) {
110
197
delegate .configurationParameter (key , value );
111
198
return this ;
112
199
}
113
200
201
+ /**
202
+ * Add all the supplied configuration parameters to the request.
203
+ *
204
+ * @param configurationParameters the map of configuration parameters to add;
205
+ * never {@code null}
206
+ * @return this builder for method chaining
207
+ * @see #configurationParameter(String, String)
208
+ */
114
209
public SuiteLauncherDiscoveryRequestBuilder configurationParameters (Map <String , String > configurationParameters ) {
115
210
delegate .configurationParameters (configurationParameters );
116
211
return this ;
117
212
}
118
213
214
+ /**
215
+ * Set the parent configuration parameters to use for the request.
216
+ *
217
+ * <p>Any explicit configuration parameters configured via
218
+ * {@link #configurationParameter(String, String)} or
219
+ * {@link #configurationParameters(Map)} takes precedence over the supplied
220
+ * configuration parameters.
221
+ *
222
+ * @param parentConfigurationParameters the parent instance to be used for looking
223
+ * up configuration parameters that have not been explicitly configured;
224
+ * never {@code null}
225
+ * @return this builder for method chaining
226
+ *
227
+ * @see #configurationParameter(String, String)
228
+ * @see #configurationParameters(Map)
229
+ */
119
230
public SuiteLauncherDiscoveryRequestBuilder parentConfigurationParameters (
120
231
ConfigurationParameters parentConfigurationParameters ) {
121
232
this .parentConfigurationParameters = parentConfigurationParameters ;
122
233
return this ;
123
234
}
124
235
236
+ /**
237
+ * Configure whether implicit configuration parameters should be considered.
238
+ *
239
+ * <p>By default, in addition to those parameters that are passed explicitly
240
+ * to this builder, configuration parameters are read from system properties
241
+ * and from the {@code junit-platform.properties} classpath resource.
242
+ * Passing {@code false} to this method, disables the latter two sources so
243
+ * that only explicit configuration parameters are taken into account.
244
+ * @return this builder for method chaining
245
+ *
246
+ * @see #configurationParameter(String, String)
247
+ * @see #configurationParameters(Map)
248
+ */
125
249
public SuiteLauncherDiscoveryRequestBuilder enableImplicitConfigurationParameters (boolean enabled ) {
126
250
delegate .enableImplicitConfigurationParameters (enabled );
127
251
return this ;
128
252
}
129
253
254
+ /**
255
+ * Configures the suite class for the suite launcher discovery request.
256
+ *
257
+ * <p>This method processes annotations on the suite class to customize
258
+ * the suite discovery and execution.
259
+ *
260
+ * @param suiteClass the suite class to configure
261
+ * @return this builder for method chaining
262
+ */
130
263
public SuiteLauncherDiscoveryRequestBuilder suite (Class <?> suiteClass ) {
131
264
Preconditions .notNull (suiteClass , "Suite class must not be null" );
132
265
@@ -198,6 +331,10 @@ public SuiteLauncherDiscoveryRequestBuilder suite(Class<?> suiteClass) {
198
331
return this ;
199
332
}
200
333
334
+ /**
335
+ * Build the {@link LauncherDiscoveryRequest} that has been configured via
336
+ * this builder.
337
+ */
201
338
public LauncherDiscoveryRequest build () {
202
339
if (filterStandardClassNamePatterns && !includeClassNamePatternsUsed ) {
203
340
delegate .filters (createIncludeClassNameFilter (STANDARD_INCLUDE_PATTERN ));
0 commit comments