-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathConstants.java
404 lines (364 loc) · 15.9 KB
/
Constants.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
/*
* Copyright 2015-2024 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at
*
* https://www.eclipse.org/legal/epl-v20.html
*/
package org.junit.jupiter.engine;
import static org.apiguardian.api.API.Status.DEPRECATED;
import static org.apiguardian.api.API.Status.EXPERIMENTAL;
import static org.apiguardian.api.API.Status.STABLE;
import static org.junit.platform.engine.support.hierarchical.DefaultParallelExecutionConfigurationStrategy.CONFIG_CUSTOM_CLASS_PROPERTY_NAME;
import static org.junit.platform.engine.support.hierarchical.DefaultParallelExecutionConfigurationStrategy.CONFIG_DYNAMIC_FACTOR_PROPERTY_NAME;
import static org.junit.platform.engine.support.hierarchical.DefaultParallelExecutionConfigurationStrategy.CONFIG_DYNAMIC_TEST_EXECUTOR_PROPERTY_NAME;
import static org.junit.platform.engine.support.hierarchical.DefaultParallelExecutionConfigurationStrategy.CONFIG_FIXED_MAX_POOL_SIZE_PROPERTY_NAME;
import static org.junit.platform.engine.support.hierarchical.DefaultParallelExecutionConfigurationStrategy.CONFIG_FIXED_PARALLELISM_PROPERTY_NAME;
import static org.junit.platform.engine.support.hierarchical.DefaultParallelExecutionConfigurationStrategy.CONFIG_FIXED_SATURATE_PROPERTY_NAME;
import static org.junit.platform.engine.support.hierarchical.DefaultParallelExecutionConfigurationStrategy.CONFIG_FIXED_TEST_EXECUTOR_PROPERTY_NAME;
import static org.junit.platform.engine.support.hierarchical.DefaultParallelExecutionConfigurationStrategy.CONFIG_STRATEGY_PROPERTY_NAME;
import org.apiguardian.api.API;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.ClassOrderer;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.engine.config.JupiterConfiguration;
import org.junit.platform.commons.util.ClassNamePatternFilterUtils;
import org.junit.platform.engine.support.hierarchical.ParallelExecutionConfigurationStrategy;
/**
* Collection of constants related to the {@link JupiterTestEngine}.
*
* @since 5.0
* @see org.junit.platform.engine.ConfigurationParameters
*/
@API(status = STABLE, since = "5.0")
public final class Constants {
/**
* Property name used to provide patterns for deactivating conditions: {@value}
*
* <h4>Pattern Matching Syntax</h4>
*
* <p>If the property value consists solely of an asterisk ({@code *}), all
* conditions will be deactivated. Otherwise, the property value will be treated
* as a comma-separated list of patterns where each individual pattern will be
* matched against the fully qualified class name (<em>FQCN</em>) of each registered
* condition. Any dot ({@code .}) in a pattern will match against a dot ({@code .})
* or a dollar sign ({@code $}) in a FQCN. Any asterisk ({@code *}) will match
* against one or more characters in a FQCN. All other characters in a pattern
* will be matched one-to-one against a FQCN.
*
* <h4>Examples</h4>
*
* <ul>
* <li>{@code *}: deactivates all conditions.
* <li>{@code org.junit.*}: deactivates every condition under the {@code org.junit}
* base package and any of its subpackages.
* <li>{@code *.MyCondition}: deactivates every condition whose simple class name is
* exactly {@code MyCondition}.
* <li>{@code *System*}: deactivates every condition whose FQCN contains
* {@code System}.
* <li>{@code *System*, *Dev*}: deactivates every condition whose FQCN contains
* {@code System} or {@code Dev}.
* <li>{@code org.example.MyCondition, org.example.TheirCondition}: deactivates
* conditions whose FQCN is exactly {@code org.example.MyCondition} or
* {@code org.example.TheirCondition}.
* </ul>
*
* @see #DEACTIVATE_ALL_CONDITIONS_PATTERN
* @see org.junit.jupiter.api.extension.ExecutionCondition
*/
public static final String DEACTIVATE_CONDITIONS_PATTERN_PROPERTY_NAME = JupiterConfiguration.DEACTIVATE_CONDITIONS_PATTERN_PROPERTY_NAME;
/**
* Wildcard pattern which signals that all conditions should be deactivated: {@value}
*
* @see #DEACTIVATE_CONDITIONS_PATTERN_PROPERTY_NAME
* @see org.junit.jupiter.api.extension.ExecutionCondition
*/
public static final String DEACTIVATE_ALL_CONDITIONS_PATTERN = ClassNamePatternFilterUtils.DEACTIVATE_ALL_PATTERN;
/**
* Property name used to set the default display name generator class name: {@value}
*
* @see DisplayNameGenerator#DEFAULT_GENERATOR_PROPERTY_NAME
*/
public static final String DEFAULT_DISPLAY_NAME_GENERATOR_PROPERTY_NAME = DisplayNameGenerator.DEFAULT_GENERATOR_PROPERTY_NAME;
/**
* Property name used to enable auto-detection and registration of extensions via
* Java's {@link java.util.ServiceLoader} mechanism: {@value}
*
* <p>The default behavior is not to perform auto-detection.
*/
public static final String EXTENSIONS_AUTODETECTION_ENABLED_PROPERTY_NAME = JupiterConfiguration.EXTENSIONS_AUTODETECTION_ENABLED_PROPERTY_NAME;
/**
* Property name used to set the default test instance lifecycle mode: {@value}
*
* @see TestInstance.Lifecycle#DEFAULT_LIFECYCLE_PROPERTY_NAME
*/
public static final String DEFAULT_TEST_INSTANCE_LIFECYCLE_PROPERTY_NAME = TestInstance.Lifecycle.DEFAULT_LIFECYCLE_PROPERTY_NAME;
/**
* Property name used to enable parallel test execution: {@value}
*
* <p>By default, tests are executed sequentially in a single thread.
*
* @since 5.3
*/
@API(status = STABLE, since = "5.10")
public static final String PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME = JupiterConfiguration.PARALLEL_EXECUTION_ENABLED_PROPERTY_NAME;
/**
* Property name used to set the default test execution mode: {@value}
*
* @see Execution#DEFAULT_EXECUTION_MODE_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_PARALLEL_EXECUTION_MODE = Execution.DEFAULT_EXECUTION_MODE_PROPERTY_NAME;
/**
* Property name used to set the default test execution mode for top-level
* classes: {@value}
*
* @see Execution#DEFAULT_CLASSES_EXECUTION_MODE_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_CLASSES_EXECUTION_MODE_PROPERTY_NAME = Execution.DEFAULT_CLASSES_EXECUTION_MODE_PROPERTY_NAME;
static final String PARALLEL_CONFIG_PREFIX = "junit.jupiter.execution.parallel.config.";
/**
* Property name used to select the
* {@link ParallelExecutionConfigurationStrategy}: {@value}
*
* <p>Potential values: {@code dynamic} (default), {@code fixed}, or
* {@code custom}.
*
* @since 5.3
*/
@API(status = STABLE, since = "5.10")
public static final String PARALLEL_CONFIG_STRATEGY_PROPERTY_NAME = PARALLEL_CONFIG_PREFIX
+ CONFIG_STRATEGY_PROPERTY_NAME;
/**
* Property name used to set the desired parallelism for the {@code fixed}
* configuration strategy: {@value}
*
* <p>No default value; must be a positive integer.
*
* @since 5.3
*/
@API(status = STABLE, since = "5.10")
public static final String PARALLEL_CONFIG_FIXED_PARALLELISM_PROPERTY_NAME = PARALLEL_CONFIG_PREFIX
+ CONFIG_FIXED_PARALLELISM_PROPERTY_NAME;
/**
* Property name used to configure the maximum pool size of the underlying
* fork-join pool for the {@code fixed} configuration strategy: {@value}
*
* <p>Value must be an integer and greater than or equal to
* {@value #PARALLEL_CONFIG_FIXED_PARALLELISM_PROPERTY_NAME}; defaults to
* {@code 256 + fixed.parallelism}.
*
* <p>Note: This property only takes effect on Java 9+.
*
* @since 5.10
*/
@API(status = EXPERIMENTAL, since = "5.10")
public static final String PARALLEL_CONFIG_FIXED_MAX_POOL_SIZE_PROPERTY_NAME = PARALLEL_CONFIG_PREFIX
+ CONFIG_FIXED_MAX_POOL_SIZE_PROPERTY_NAME;
/**
* Property name used to disable saturation of the underlying fork-join pool
* for the {@code fixed} configuration strategy: {@value}
*
* <p>When set to {@code false} the underlying fork-join pool will reject
* additional tasks if all available workers are busy and the maximum
* pool-size would be exceeded.
* <p>Value must either {@code true} or {@code false}; defaults to {@code true}.
*
* <p>Note: This property only takes effect on Java 9+.
*
* @since 5.10
*/
@API(status = EXPERIMENTAL, since = "5.10")
public static final String PARALLEL_CONFIG_FIXED_SATURATE_PROPERTY_NAME = PARALLEL_CONFIG_PREFIX
+ CONFIG_FIXED_SATURATE_PROPERTY_NAME;
/**
* Property name used to set the type of test executor
* (which directly relates to the type of thread pool used)
* for the {@code fixed} configuration strategy: {@value}
*
* <p>Value must be either {@code fork_join} or {@code fixed_threads}; defaults to {@code fork_join}.
*
* @since 5.11
*/
@API(status = EXPERIMENTAL, since = "5.11")
public static final String PARALLEL_CONFIG_FIXED_TEST_EXECUTOR_PROPERTY_NAME = PARALLEL_CONFIG_PREFIX
+ CONFIG_FIXED_TEST_EXECUTOR_PROPERTY_NAME;
/**
* Property name used to set the factor to be multiplied with the number of
* available processors/cores to determine the desired parallelism for the
* {@code dynamic} configuration strategy: {@value}
*
* <p>Value must be a positive decimal number; defaults to {@code 1}.
*
* @since 5.3
*/
@API(status = STABLE, since = "5.10")
public static final String PARALLEL_CONFIG_DYNAMIC_FACTOR_PROPERTY_NAME = PARALLEL_CONFIG_PREFIX
+ CONFIG_DYNAMIC_FACTOR_PROPERTY_NAME;
/**
* Property name used to set the type of test executor
* (which directly relates to the type of thread pool used)
* for the {@code dynamic} configuration strategy: {@value}
*
* <p>Value must be either {@code fork_join} or {@code fixed_threads}; defaults to {@code fork_join}.
*
* @since 5.11
*/
@API(status = EXPERIMENTAL, since = "5.11")
public static final String PARALLEL_CONFIG_DYNAMIC_TEST_EXECUTOR_PROPERTY_NAME = PARALLEL_CONFIG_PREFIX
+ CONFIG_DYNAMIC_TEST_EXECUTOR_PROPERTY_NAME;
/**
* Property name used to specify the fully qualified class name of the
* {@link ParallelExecutionConfigurationStrategy} to be used for the
* {@code custom} configuration strategy: {@value}
*
* @since 5.3
*/
@API(status = STABLE, since = "5.10")
public static final String PARALLEL_CONFIG_CUSTOM_CLASS_PROPERTY_NAME = PARALLEL_CONFIG_PREFIX
+ CONFIG_CUSTOM_CLASS_PROPERTY_NAME;
/**
* Property name used to set the default timeout for all testable and
* lifecycle methods: {@value}.
*
* @see Timeout#DEFAULT_TIMEOUT_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_TIMEOUT_PROPERTY_NAME = Timeout.DEFAULT_TIMEOUT_PROPERTY_NAME;
/**
* Property name used to set the default timeout for all testable methods: {@value}.
*
* @see Timeout#DEFAULT_TESTABLE_METHOD_TIMEOUT_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_TESTABLE_METHOD_TIMEOUT_PROPERTY_NAME = Timeout.DEFAULT_TESTABLE_METHOD_TIMEOUT_PROPERTY_NAME;
/**
* Property name used to set the default timeout for all
* {@link Test @Test} methods: {@value}.
*
* @see Timeout#DEFAULT_TEST_METHOD_TIMEOUT_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_TEST_METHOD_TIMEOUT_PROPERTY_NAME = Timeout.DEFAULT_TEST_METHOD_TIMEOUT_PROPERTY_NAME;
/**
* Property name used to set the default timeout for all
* {@link TestTemplate @TestTemplate} methods: {@value}.
*
* @see Timeout#DEFAULT_TEST_TEMPLATE_METHOD_TIMEOUT_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_TEST_TEMPLATE_METHOD_TIMEOUT_PROPERTY_NAME = Timeout.DEFAULT_TEST_TEMPLATE_METHOD_TIMEOUT_PROPERTY_NAME;
/**
* Property name used to set the default timeout for all
* {@link TestFactory @TestFactory} methods: {@value}.
*
* @see Timeout#DEFAULT_TEST_FACTORY_METHOD_TIMEOUT_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_TEST_FACTORY_METHOD_TIMEOUT_PROPERTY_NAME = Timeout.DEFAULT_TEST_FACTORY_METHOD_TIMEOUT_PROPERTY_NAME;
/**
* Property name used to set the default timeout for all lifecycle methods: {@value}.
*
* @see Timeout#DEFAULT_LIFECYCLE_METHOD_TIMEOUT_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_LIFECYCLE_METHOD_TIMEOUT_PROPERTY_NAME = Timeout.DEFAULT_LIFECYCLE_METHOD_TIMEOUT_PROPERTY_NAME;
/**
* Property name used to set the default timeout for all
* {@link BeforeAll @BeforeAll} methods: {@value}.
*
* @see Timeout#DEFAULT_BEFORE_ALL_METHOD_TIMEOUT_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_BEFORE_ALL_METHOD_TIMEOUT_PROPERTY_NAME = Timeout.DEFAULT_BEFORE_ALL_METHOD_TIMEOUT_PROPERTY_NAME;
/**
* Property name used to set the default timeout for all
* {@link BeforeEach @BeforeEach} methods: {@value}.
*
* @see Timeout#DEFAULT_BEFORE_EACH_METHOD_TIMEOUT_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_BEFORE_EACH_METHOD_TIMEOUT_PROPERTY_NAME = Timeout.DEFAULT_BEFORE_EACH_METHOD_TIMEOUT_PROPERTY_NAME;
/**
* Property name used to set the default timeout for all
* {@link AfterEach @AfterEach} methods: {@value}.
*
* @see Timeout#DEFAULT_AFTER_EACH_METHOD_TIMEOUT_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_AFTER_EACH_METHOD_TIMEOUT_PROPERTY_NAME = Timeout.DEFAULT_AFTER_EACH_METHOD_TIMEOUT_PROPERTY_NAME;
/**
* Property name used to set the default timeout for all
* {@link AfterAll @AfterAll} methods: {@value}.
*
* @see Timeout#DEFAULT_AFTER_ALL_METHOD_TIMEOUT_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String DEFAULT_AFTER_ALL_METHOD_TIMEOUT_PROPERTY_NAME = Timeout.DEFAULT_AFTER_ALL_METHOD_TIMEOUT_PROPERTY_NAME;
/**
* Property name used to configure whether timeouts are applied to tests: {@value}.
*
* @see Timeout#TIMEOUT_MODE_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.10")
public static final String TIMEOUT_MODE_PROPERTY_NAME = Timeout.TIMEOUT_MODE_PROPERTY_NAME;
/**
* Property name used to set the default method orderer class name: {@value}
*
* @see MethodOrderer#DEFAULT_ORDER_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.9")
public static final String DEFAULT_TEST_METHOD_ORDER_PROPERTY_NAME = MethodOrderer.DEFAULT_ORDER_PROPERTY_NAME;
/**
* Property name used to set the default class orderer class name: {@value}
*
* @see ClassOrderer#DEFAULT_ORDER_PROPERTY_NAME
*/
@API(status = STABLE, since = "5.9")
public static final String DEFAULT_TEST_CLASS_ORDER_PROPERTY_NAME = ClassOrderer.DEFAULT_ORDER_PROPERTY_NAME;
/**
* Property name used to set the scope of temporary directories created via
* the {@link TempDir @TempDir} annotation: {@value}
*
* @see TempDir#SCOPE_PROPERTY_NAME
*/
@Deprecated
@API(status = DEPRECATED, since = "5.8")
@SuppressWarnings("deprecation")
public static final String TEMP_DIR_SCOPE_PROPERTY_NAME = TempDir.SCOPE_PROPERTY_NAME;
/**
* Property name used to set the default timeout thread mode.
*
* @since 5.9
* @see Timeout
* @see Timeout.ThreadMode
*/
@API(status = EXPERIMENTAL, since = "5.9")
public static final String DEFAULT_TIMEOUT_THREAD_MODE_PROPERTY_NAME = Timeout.DEFAULT_TIMEOUT_THREAD_MODE_PROPERTY_NAME;
/**
* Property name used to set the default factory for temporary directories created via
* the {@link TempDir @TempDir} annotation: {@value}
*
* @since 5.10
* @see TempDir#DEFAULT_FACTORY_PROPERTY_NAME
*/
@API(status = EXPERIMENTAL, since = "5.10")
public static final String DEFAULT_TEMP_DIR_FACTORY_PROPERTY_NAME = TempDir.DEFAULT_FACTORY_PROPERTY_NAME;
private Constants() {
/* no-op */
}
}