1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.maven.plugin.surefire; 20 21 import java.io.File; 22 import java.util.Arrays; 23 import java.util.Collections; 24 import java.util.List; 25 26 import org.apache.maven.plugin.MojoExecutionException; 27 import org.apache.maven.plugin.MojoFailureException; 28 import org.apache.maven.plugin.surefire.booterclient.ChecksumCalculator; 29 import org.apache.maven.plugins.annotations.LifecyclePhase; 30 import org.apache.maven.plugins.annotations.Mojo; 31 import org.apache.maven.plugins.annotations.Parameter; 32 import org.apache.maven.plugins.annotations.ResolutionScope; 33 import org.apache.maven.surefire.api.suite.RunResult; 34 import org.apache.maven.surefire.extensions.ForkNodeFactory; 35 36 import static org.apache.maven.plugin.surefire.SurefireHelper.reportExecution; 37 38 /** 39 * Run tests using Surefire. 40 * 41 * @author Jason van Zyl 42 */ 43 @Mojo( 44 name = "test", 45 defaultPhase = LifecyclePhase.TEST, 46 threadSafe = true, 47 requiresDependencyResolution = ResolutionScope.TEST) 48 public class SurefireMojo extends AbstractSurefireMojo implements SurefireReportParameters { 49 50 /** 51 * The directory containing generated classes of the project being tested. This will be included after the test 52 * classes in the test classpath. 53 */ 54 @Parameter(defaultValue = "${project.build.outputDirectory}") 55 private File classesDirectory; 56 57 /** 58 * Set this to "true" to ignore a failure during testing. Its use is NOT RECOMMENDED, but quite convenient on 59 * occasion. 60 */ 61 @Parameter(property = "maven.test.failure.ignore", defaultValue = "false") 62 private boolean testFailureIgnore; 63 64 /** 65 * Base directory where all reports are written to. 66 */ 67 @Parameter(defaultValue = "${project.build.directory}/surefire-reports") 68 private File reportsDirectory; 69 70 @SuppressWarnings("checkstyle:linelength") 71 /** 72 * Specify this parameter to run individual tests by file name, overriding the parameter {@code includes} and 73 * {@code excludes}. Each pattern you specify here will be used to create an include pattern formatted like 74 * <code>**{@literal /}${test}.java</code>, so you can just type {@code -Dtest=MyTest} to run a single test called 75 * "foo/MyTest.java". The test patterns prefixed with a <em>!</em> will be excluded. 76 * <br> 77 * This parameter overrides the parameter {@code includes}, {@code excludes}, and the TestNG parameter 78 * {@code suiteXmlFiles}. 79 * <br> 80 * Since 2.7.3, you can execute a limited number of methods in the test by adding <i>#myMethod</i> or 81 * <i>#my*ethod</i>. For example, {@code -Dtest=MyTest#myMethod}. This is supported for junit 4.x and TestNg.<br> 82 * <br> 83 * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): 84 * <pre><code>"-Dtest=???Test, !Unstable*, pkg{@literal /}**{@literal /}Ci*leTest.java, *Test#test*One+testTwo?????, #fast*+slowTest"</code></pre> 85 * or e.g. 86 * <pre><code>"-Dtest=Basic*, !%regex[.*.Unstable.*], !%regex[.*.MyTest.class#one.*|two.*], %regex[#fast.*|slow.*]"</code></pre> 87 * <br> 88 * The Parameterized JUnit runner {@code describes} test methods using an index in brackets, so the non-regex 89 * method pattern would become: {@code #testMethod[*]}. 90 * If using <code>@Parameters(name="{index}: fib({0})={1}")</code> and selecting the index e.g. 5 in pattern, the 91 * non-regex method pattern would become {@code #testMethod[5:*]}. 92 */ 93 @Parameter(property = "test") 94 private String test; 95 96 /** 97 * Option to print summary of test suites or just print the test cases that have errors. 98 */ 99 @Parameter(property = "surefire.printSummary", defaultValue = "true") 100 private boolean printSummary; 101 102 /** 103 * Selects the formatting for the test report to be generated. Can be set as "brief" or "plain". 104 * Only applies to the output format of the output files (target/surefire-reports/testName.txt) 105 */ 106 @Parameter(property = "surefire.reportFormat", defaultValue = "brief") 107 private String reportFormat; 108 109 /** 110 * Option to generate a file test report or just output the test report to the console. 111 */ 112 @Parameter(property = "surefire.useFile", defaultValue = "true") 113 private boolean useFile; 114 115 /** 116 * Set this to "true" to cause a failure if none of the tests specified in -Dtest=... are run. Defaults to 117 * "true". 118 * 119 * @since 2.12 120 */ 121 @Parameter(property = "surefire.failIfNoSpecifiedTests", defaultValue = "true") 122 private boolean failIfNoSpecifiedTests; 123 124 /** 125 * Attach a debugger to the forked JVM. If set to "true", the process will suspend and wait for a debugger to attach 126 * on port 5005. If set to some other string, that string will be appended to the argLine, allowing you to configure 127 * arbitrary debuggability options (without overwriting the other options specified through the {@code argLine} 128 * parameter). 129 * 130 * @since 2.4 131 */ 132 @Parameter(property = "maven.surefire.debug") 133 private String debugForkedProcess; 134 135 /** 136 * Kill the forked test process after a certain number of seconds. If set to 0, wait forever for the process, never 137 * timing out. 138 * 139 * @since 2.4 140 */ 141 @Parameter(property = "surefire.timeout") 142 private int forkedProcessTimeoutInSeconds; 143 144 /** 145 * Forked process is normally terminated without any significant delay after given tests have completed. 146 * If the particular tests started non-daemon Thread(s), the process hangs instead of been properly terminated 147 * by {@code System.exit()}. Use this parameter in order to determine the timeout of terminating the process. 148 * <a href="http://maven.apache.org/surefire/maven-surefire-plugin/examples/shutdown.html">see the documentation: 149 * http://maven.apache.org/surefire/maven-surefire-plugin/examples/shutdown.html</a> 150 * Turns to default fallback value of 30 seconds if negative integer. 151 * 152 * @since 2.20 153 */ 154 @Parameter(property = "surefire.exitTimeout", defaultValue = "30") 155 private int forkedProcessExitTimeoutInSeconds; 156 157 /** 158 * Stop executing queued parallel JUnit tests after a certain number of seconds. 159 * <br> 160 * Example values: "3.5", "4"<br> 161 * <br> 162 * If set to 0, wait forever, never timing out. 163 * Makes sense with specified {@code parallel} different from "none". 164 * 165 * @since 2.16 166 */ 167 @Parameter(property = "surefire.parallel.timeout") 168 private double parallelTestsTimeoutInSeconds; 169 170 /** 171 * Stop executing queued parallel JUnit tests 172 * and {@code interrupt} currently running tests after a certain number of seconds. 173 * <br> 174 * Example values: "3.5", "4"<br> 175 * <br> 176 * If set to 0, wait forever, never timing out. 177 * Makes sense with specified {@code parallel} different from "none". 178 * 179 * @since 2.16 180 */ 181 @Parameter(property = "surefire.parallel.forcedTimeout") 182 private double parallelTestsTimeoutForcedInSeconds; 183 184 @SuppressWarnings("checkstyle:linelength") 185 /** 186 * A list of {@literal <include>} elements specifying the tests (by pattern) that should be included in testing. 187 * When not specified and when the {@code test} parameter is not specified, the default includes will be 188 * <pre><code> 189 * {@literal <includes>} 190 * {@literal <include>}**{@literal /}Test*.java{@literal </include>} 191 * {@literal <include>}**{@literal /}*Test.java{@literal </include>} 192 * {@literal <include>}**{@literal /}*Tests.java{@literal </include>} 193 * {@literal <include>}**{@literal /}*TestCase.java{@literal </include>} 194 * {@literal </includes>} 195 * </code></pre> 196 * Each include item may also contain a comma-separated sub-list of items, which will be treated as multiple 197 * {@literal <include>} entries.<br> 198 * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): 199 * <pre><code> 200 * {@literal <include>}%regex[.*[Cat|Dog].*], Basic????, !Unstable*{@literal </include>} 201 * {@literal <include>}%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg{@literal /}**{@literal /}*Fast*.java{@literal </include>} 202 * </code></pre> 203 * <br> 204 * This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified.<br> 205 * <br> 206 * <b>Notice that</b> these values are relative to the directory containing generated test classes of the project 207 * being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults 208 * to the POM property {@code ${project.build.testOutputDirectory}}, typically 209 * <code>{@literal src/test/java}</code> unless overridden. 210 */ 211 @Parameter(property = "surefire.includes") 212 // TODO use regex for fully qualified class names in 3.0 and change the filtering abilities 213 private List<String> includes; 214 215 /** 216 * A list of {@literal <exclude>} elements specifying the tests (by pattern) that should be excluded in testing. 217 * When not specified and when the {@code test} parameter is not specified, the default excludes will be <br> 218 * <pre><code> 219 * {@literal <excludes>} 220 * {@literal <exclude>}**{@literal /}*$*{@literal </exclude>} 221 * {@literal </excludes>} 222 * </code></pre> 223 * (which excludes all inner classes). 224 * <br> 225 * This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified. 226 * <br> 227 * Each exclude item may also contain a comma-separated sub-list of items, which will be treated as multiple 228 * {@literal <exclude>} entries.<br> 229 * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG): 230 * <pre><code> 231 * {@literal <exclude>}%regex[pkg.*Slow.*.class], Unstable*{@literal </exclude>} 232 * </code></pre> 233 * <br> 234 * <b>Notice that</b> these values are relative to the directory containing generated test classes of the project 235 * being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults 236 * to the POM property <code>${project.build.testOutputDirectory}</code>, typically 237 * <code>{@literal src/test/java}</code> unless overridden. 238 */ 239 @Parameter(property = "surefire.excludes") 240 // TODO use regex for fully qualified class names in 3.0 and change the filtering abilities 241 private List<String> excludes; 242 243 /** 244 * Option to pass dependencies to the system's classloader instead of using an isolated class loader when forking. 245 * Prevents problems with JDKs which implement the service provider lookup mechanism by using the system's 246 * ClassLoader. 247 * 248 * @since 2.3 249 */ 250 @Parameter(property = "surefire.useSystemClassLoader", defaultValue = "true") 251 private boolean useSystemClassLoader; 252 253 /** 254 * By default, Surefire forks your tests using a manifest-only JAR; set this parameter to "false" to force it to 255 * launch your tests with a plain old Java classpath. (See the 256 * <a href="http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html"> 257 * http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html</a> 258 * for a more detailed explanation of manifest-only JARs and their benefits.) 259 * <br> 260 * Beware, setting this to "false" may cause your tests to fail on Windows if your classpath is too long. 261 * 262 * @since 2.4.3 263 */ 264 @Parameter(property = "surefire.useManifestOnlyJar", defaultValue = "true") 265 private boolean useManifestOnlyJar; 266 267 /** 268 * The character encoding scheme to be applied while generating test report 269 * files (see target/surefire-reports/yourTestName.txt). 270 * The report output files (*-out.txt) are encoded in UTF-8 if not set otherwise. 271 * 272 * @since 3.0.0-M1 273 */ 274 @Parameter(property = "surefire.encoding", defaultValue = "${project.reporting.outputEncoding}") 275 private String encoding; 276 277 /** 278 * (JUnit 4+ providers and JUnit 5+ providers since 3.0.0-M4) 279 * The number of times each failing test will be rerun. If set larger than 0, rerun failing tests immediately after 280 * they fail. If a failing test passes in any of those reruns, it will be marked as pass and reported as a "flake". 281 * However, all the failing attempts will be recorded. 282 */ 283 @Parameter(property = "surefire.rerunFailingTestsCount", defaultValue = "0") 284 private int rerunFailingTestsCount; 285 286 /** 287 * Set this to a value greater than 0 to fail the whole test set if the cumulative number of flakes reaches 288 * this threshold. Set to 0 to allow an unlimited number of flakes. 289 * 290 * @since 3.0.0-M6 291 */ 292 @Parameter(property = "surefire.failOnFlakeCount", defaultValue = "0") 293 private int failOnFlakeCount; 294 295 /** 296 * (TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note that 297 * {@code suiteXmlFiles} is incompatible with several other parameters of this plugin, like 298 * {@code includes} and {@code excludes}.<br> 299 * This parameter is ignored if the {@code test} parameter is specified (allowing you to run a single test 300 * instead of an entire suite). 301 * 302 * @since 2.2 303 */ 304 @Parameter(property = "surefire.suiteXmlFiles") 305 private File[] suiteXmlFiles; 306 307 /** 308 * Defines the order the tests will be run in. Supported values are {@code alphabetical}, 309 * {@code reversealphabetical}, {@code random}, {@code hourly} (alphabetical on even hours, reverse alphabetical 310 * on odd hours), {@code failedfirst}, {@code balanced} and {@code filesystem}. 311 * <br> 312 * <br> 313 * Odd/Even for hourly is determined at the time the of scanning the classpath, meaning it could change during a 314 * multi-module build. 315 * <br> 316 * <br> 317 * Failed first will run tests that failed on previous run first, as well as new tests for this run. 318 * <br> 319 * <br> 320 * Balanced is only relevant with parallel=classes, and will try to optimize the run-order of the tests reducing the 321 * overall execution time. Initially a statistics file is created and every next test run will reorder classes. 322 * <br> 323 * <br> 324 * Note that the statistics are stored in a file named <b>.surefire-XXXXXXXXX</b> beside <i>pom.xml</i> and 325 * should not be checked into version control. The "XXXXX" is the SHA1 checksum of the entire surefire 326 * configuration, so different configurations will have different statistics files, meaning if you change any 327 * configuration settings you will re-run once before new statistics data can be established. 328 * 329 * @since 2.7 330 */ 331 @Parameter(property = "surefire.runOrder", defaultValue = "filesystem") 332 private String runOrder; 333 334 /** 335 * Sets the random seed that will be used to order the tests if {@code surefire.runOrder} is set to {@code random}. 336 * <br> 337 * <br> 338 * If no seeds are set and {@code surefire.runOrder} is set to {@code random}, then the seed used will be 339 * outputted (search for "To reproduce ordering use flag -Dsurefire.runOrder.random.seed"). 340 * <br> 341 * <br> 342 * To deterministically reproduce any random test order that was run before, simply set the seed to 343 * be the same value. 344 * 345 * @since 3.0.0-M6 346 */ 347 @Parameter(property = "surefire.runOrder.random.seed") 348 private Long runOrderRandomSeed; 349 350 /** 351 * Used to override the checksum in the name of the statistics file 352 * when {@code surefire.runOrder} is set to "balanced". 353 * 354 * @since 3.5.5 355 */ 356 @Parameter(property = "surefire.runOrder.statisticsFile.checksum") 357 private String runOrderStatisticsFileChecksum; 358 359 /** 360 * A file containing include patterns. Blank lines, or lines starting with # are ignored. If {@code includes} are 361 * also specified, these patterns are appended. Example with path, simple and regex includes: 362 * <pre><code> 363 * *{@literal /}test{@literal /}* 364 * **{@literal /}NotIncludedByDefault.java 365 * %regex[.*Test.*|.*Not.*] 366 * </code></pre> 367 * <br> 368 * Since 3.0.0-M6, method filtering support is provided in the inclusions file as well, example: 369 * <pre><code> 370 * pkg.SomeTest#testMethod 371 * </code></pre> 372 * 373 * @since 2.13 374 */ 375 @Parameter(property = "surefire.includesFile") 376 private File includesFile; 377 378 /** 379 * A file containing exclude patterns. Blank lines, or lines starting with # are ignored. If {@code excludes} are 380 * also specified, these patterns are appended. Example with path, simple and regex excludes:<br> 381 * <pre><code> 382 * *{@literal /}test{@literal /}* 383 * **{@literal /}DontRunTest.* 384 * %regex[.*Test.*|.*Not.*] 385 * </code></pre> 386 * 387 * Since 3.0.0-M6, method filtering support is provided in the exclusions file as well, example: 388 * <pre><code> 389 * pkg.SomeTest#testMethod 390 * </code></pre> 391 * 392 * @since 2.13 393 */ 394 @Parameter(property = "surefire.excludesFile") 395 private File excludesFile; 396 397 /** 398 * Set to error/failure count in order to skip remaining tests. 399 * Due to race conditions in parallel/forked execution this may not be fully guaranteed.<br> 400 * Enable with system property {@code -Dsurefire.skipAfterFailureCount=1} or any number greater than zero. 401 * Defaults to "0".<br> 402 * See the prerequisites and limitations in documentation:<br> 403 * <a href="http://maven.apache.org/plugins/maven-surefire-plugin/examples/skip-after-failure.html"> 404 * http://maven.apache.org/plugins/maven-surefire-plugin/examples/skip-after-failure.html</a> 405 * 406 * @since 2.19 407 */ 408 @Parameter(property = "surefire.skipAfterFailureCount", defaultValue = "0") 409 private int skipAfterFailureCount; 410 411 /** 412 * After the plugin process is shutdown by sending <i>SIGTERM signal (CTRL+C)</i>, <i>SHUTDOWN command</i> is 413 * received by every forked JVM. 414 * <br> 415 * The value is set to ({@code shutdown=exit}) by default (changed in version 3.0.0-M4). 416 * <br> 417 * The parameter can be configured with other two values {@code testset} and {@code kill}. 418 * <br> 419 * With({@code shutdown=testset}) the test set may still continue to run in forked JVM. 420 * <br> 421 * Using {@code exit} forked JVM executes {@code System.exit(1)} after the plugin process has received 422 * <i>SIGTERM signal</i>. 423 * <br> 424 * Using {@code kill} the JVM executes {@code Runtime.halt(1)} and kills itself. 425 * 426 * @since 2.19 427 */ 428 @Parameter(property = "surefire.shutdown", defaultValue = "exit") 429 private String shutdown; 430 431 /** 432 * When {@code true}, uses the modulepath when executing with JDK 9+ and <i>module-info.java</i> is 433 * present. When {@code false}, always uses the classpath. 434 * <br> 435 * Defaults to {@code true}. 436 * 437 * @since 3.0.0-M2 438 */ 439 @Parameter(property = "surefire.useModulePath", defaultValue = "true") 440 private boolean useModulePath; 441 442 /** 443 * This parameter configures the forked node. Currently, you can select the communication protocol, i.e. process 444 * pipes or TCP/IP sockets. 445 * The plugin uses process pipes by default which will be turned to TCP/IP in the version 3.0.0. 446 * Alternatively, you can implement your own factory and SPI. 447 * <br> 448 * See the documentation for more details:<br> 449 * <a href="https://maven.apache.org/plugins/maven-surefire-plugin/examples/process-communication.html"> 450 * https://maven.apache.org/plugins/maven-surefire-plugin/examples/process-communication.html</a> 451 * 452 * @since 3.0.0-M5 453 */ 454 @Parameter(property = "surefire.forkNode") 455 private ForkNodeFactory forkNode; 456 457 /** 458 * You can selectively exclude individual environment variables by enumerating their keys. 459 * <br> 460 * The environment is a system-dependent mapping from keys to values which is inherited from the Maven process 461 * to the forked Surefire processes. The keys must literally (case sensitive) match in order to exclude 462 * their environment variable. 463 * <br> 464 * Example to exclude three environment variables: 465 * <br> 466 * <i>mvn test -Dsurefire.excludedEnvironmentVariables=ACME1,ACME2,ACME3</i> 467 * 468 * @since 3.0.0-M4 469 */ 470 @Parameter(property = "surefire.excludedEnvironmentVariables") 471 private String[] excludedEnvironmentVariables; 472 473 /** 474 * Since 3.0.0-M4 the process checkers are disabled. 475 * You can enable them namely by setting {@code ping} and {@code native} or {@code all} in this parameter. 476 * <br> 477 * The checker is useful in situations when you kill the build on a CI system and you want the Surefire forked JVM 478 * to kill the tests asap and free all handlers on the file system been previously used by the JVM and by the tests. 479 * 480 * <br> 481 * 482 * The {@code ping} should be safely used together with ZGC or Shenandoah Garbage Collector. 483 * Due to the {@code ping} relies on timing of the PING (triggered every 30 seconds), slow GCs may pause 484 * the timers and pretend that the parent process of the forked JVM does not exist. 485 * 486 * <br> 487 * 488 * The {@code native} is very fast checker. 489 * It is useful mechanism on Unix based systems, Linux distributions and Alpine/BusyBox Linux. 490 * See the JIRA <a href="https://issues.apache.org/jira/browse/SUREFIRE-1631">SUREFIRE-1631</a> for Windows issues. 491 * 492 * <br> 493 * 494 * Another useful configuration parameter is {@code forkedProcessTimeoutInSeconds}. 495 * <br> 496 * See the Frequently Asked Questions page with more details:<br> 497 * <a href="http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#kill-jvm"> 498 * http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#kill-jvm</a> 499 * <br> 500 * <a href="http://maven.apache.org/surefire/maven-failsafe-plugin/faq.html#kill-jvm"> 501 * http://maven.apache.org/surefire/maven-failsafe-plugin/faq.html#kill-jvm</a> 502 * 503 * <br> 504 * 505 * Example of use: 506 * <br> 507 * <i>mvn test -Dsurefire.enableProcessChecker=all</i> 508 * 509 * @since 3.0.0-M4 510 */ 511 @Parameter(property = "surefire.enableProcessChecker") 512 private String enableProcessChecker; 513 514 /** 515 * Properties file being used as system properties passed to the provider. 516 * 517 * @see AbstractSurefireMojo#systemPropertyVariables {@code systemPropertyVariables} for how the effective provider properties are calculated 518 */ 519 @Parameter(property = "surefire.systemPropertiesFile") 520 private File systemPropertiesFile; 521 522 /** 523 * Provide the ID/s of an JUnit engine to be included in the test run. 524 * 525 * @since 3.0.0-M6 526 */ 527 @Parameter(property = "surefire.includeJUnit5Engines") 528 private String[] includeJUnit5Engines; 529 530 /** 531 * Provide the ID/s of an JUnit engine to be excluded in the test run. 532 * 533 * @since 3.0.0-M6 534 */ 535 @Parameter(property = "surefire.excludeJUnit5Engines") 536 private String[] excludeJUnit5Engines; 537 538 @Override 539 protected int getRerunFailingTestsCount() { 540 return rerunFailingTestsCount; 541 } 542 543 @Override 544 public int getFailOnFlakeCount() { 545 return failOnFlakeCount; 546 } 547 548 @Override 549 public void setFailOnFlakeCount(int failOnFlakeCount) { 550 this.failOnFlakeCount = failOnFlakeCount; 551 } 552 553 @Override 554 protected void handleSummary(RunResult summary, Exception firstForkException) 555 throws MojoExecutionException, MojoFailureException { 556 reportExecution(this, summary, getConsoleLogger(), firstForkException); 557 } 558 559 @Override 560 protected boolean isSkipExecution() { 561 return isSkip() || isSkipTests() || isSkipExec(); 562 } 563 564 @Override 565 protected String getPluginName() { 566 return "surefire"; 567 } 568 569 @Override 570 protected String[] getDefaultIncludes() { 571 return new String[] {"**/Test*.java", "**/*Test.java", "**/*Tests.java", "**/*TestCase.java"}; 572 } 573 574 @Override 575 protected String getReportSchemaLocation() { 576 return "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd"; 577 } 578 579 public File getSystemPropertiesFile() { 580 return systemPropertiesFile; 581 } 582 583 public void setSystemPropertiesFile(File systemPropertiesFile) { 584 this.systemPropertiesFile = systemPropertiesFile; 585 } 586 587 // now for the implementation of the field accessors 588 589 @Override 590 public boolean isSkipTests() { 591 return skipTests; 592 } 593 594 @Override 595 public void setSkipTests(boolean skipTests) { 596 this.skipTests = skipTests; 597 } 598 599 @Override 600 @Deprecated 601 public boolean isSkipExec() { 602 return skipExec; 603 } 604 605 @Override 606 @Deprecated 607 public void setSkipExec(boolean skipExec) { 608 this.skipExec = skipExec; 609 } 610 611 @Override 612 public boolean isSkip() { 613 return skip; 614 } 615 616 @Override 617 public void setSkip(boolean skip) { 618 this.skip = skip; 619 } 620 621 @Override 622 public boolean isTestFailureIgnore() { 623 return testFailureIgnore; 624 } 625 626 @Override 627 public void setTestFailureIgnore(boolean testFailureIgnore) { 628 this.testFailureIgnore = testFailureIgnore; 629 } 630 631 @Override 632 public File getBasedir() { 633 return basedir; 634 } 635 636 @Override 637 public void setBasedir(File basedir) { 638 this.basedir = basedir; 639 } 640 641 @Override 642 public File getTestClassesDirectory() { 643 return testClassesDirectory; 644 } 645 646 @Override 647 public void setTestClassesDirectory(File testClassesDirectory) { 648 this.testClassesDirectory = testClassesDirectory; 649 } 650 651 @Override 652 public File getMainBuildPath() { 653 return classesDirectory; 654 } 655 656 @Override 657 public void setMainBuildPath(File mainBuildPath) { 658 classesDirectory = mainBuildPath; 659 } 660 661 @Override 662 public File getReportsDirectory() { 663 return reportsDirectory; 664 } 665 666 @Override 667 public void setReportsDirectory(File reportsDirectory) { 668 this.reportsDirectory = reportsDirectory; 669 } 670 671 @Override 672 public String getTest() { 673 return test; 674 } 675 676 @Override 677 public boolean isUseSystemClassLoader() { 678 return useSystemClassLoader; 679 } 680 681 @Override 682 public void setUseSystemClassLoader(boolean useSystemClassLoader) { 683 this.useSystemClassLoader = useSystemClassLoader; 684 } 685 686 @Override 687 public boolean isUseManifestOnlyJar() { 688 return useManifestOnlyJar; 689 } 690 691 @Override 692 public void setUseManifestOnlyJar(boolean useManifestOnlyJar) { 693 this.useManifestOnlyJar = useManifestOnlyJar; 694 } 695 696 @Override 697 public String getEncoding() { 698 return encoding; 699 } 700 701 @Override 702 public void setEncoding(String encoding) { 703 this.encoding = encoding; 704 } 705 706 @Override 707 public boolean getFailIfNoSpecifiedTests() { 708 return failIfNoSpecifiedTests; 709 } 710 711 @Override 712 public void setFailIfNoSpecifiedTests(boolean failIfNoSpecifiedTests) { 713 this.failIfNoSpecifiedTests = failIfNoSpecifiedTests; 714 } 715 716 @Override 717 public int getSkipAfterFailureCount() { 718 return skipAfterFailureCount; 719 } 720 721 @Override 722 public String getShutdown() { 723 return shutdown; 724 } 725 726 @Override 727 public boolean isPrintSummary() { 728 return printSummary; 729 } 730 731 @Override 732 public void setPrintSummary(boolean printSummary) { 733 this.printSummary = printSummary; 734 } 735 736 @Override 737 public String getReportFormat() { 738 return reportFormat; 739 } 740 741 @Override 742 public void setReportFormat(String reportFormat) { 743 this.reportFormat = reportFormat; 744 } 745 746 @Override 747 public boolean isUseFile() { 748 return useFile; 749 } 750 751 @Override 752 public void setUseFile(boolean useFile) { 753 this.useFile = useFile; 754 } 755 756 @Override 757 public String getDebugForkedProcess() { 758 return debugForkedProcess; 759 } 760 761 @Override 762 public void setDebugForkedProcess(String debugForkedProcess) { 763 this.debugForkedProcess = debugForkedProcess; 764 } 765 766 @Override 767 public int getForkedProcessTimeoutInSeconds() { 768 return forkedProcessTimeoutInSeconds; 769 } 770 771 @Override 772 public void setForkedProcessTimeoutInSeconds(int forkedProcessTimeoutInSeconds) { 773 this.forkedProcessTimeoutInSeconds = forkedProcessTimeoutInSeconds; 774 } 775 776 @Override 777 public int getForkedProcessExitTimeoutInSeconds() { 778 return forkedProcessExitTimeoutInSeconds; 779 } 780 781 @Override 782 public void setForkedProcessExitTimeoutInSeconds(int forkedProcessExitTimeoutInSeconds) { 783 this.forkedProcessExitTimeoutInSeconds = forkedProcessExitTimeoutInSeconds; 784 } 785 786 @Override 787 public double getParallelTestsTimeoutInSeconds() { 788 return parallelTestsTimeoutInSeconds; 789 } 790 791 @Override 792 public void setParallelTestsTimeoutInSeconds(double parallelTestsTimeoutInSeconds) { 793 this.parallelTestsTimeoutInSeconds = parallelTestsTimeoutInSeconds; 794 } 795 796 @Override 797 public double getParallelTestsTimeoutForcedInSeconds() { 798 return parallelTestsTimeoutForcedInSeconds; 799 } 800 801 @Override 802 public void setParallelTestsTimeoutForcedInSeconds(double parallelTestsTimeoutForcedInSeconds) { 803 this.parallelTestsTimeoutForcedInSeconds = parallelTestsTimeoutForcedInSeconds; 804 } 805 806 @Override 807 public void setTest(String test) { 808 this.test = test; 809 } 810 811 @Override 812 public List<String> getIncludes() { 813 return includes; 814 } 815 816 @Override 817 public void setIncludes(List<String> includes) { 818 this.includes = includes; 819 } 820 821 @Override 822 public List<String> getExcludes() { 823 return excludes; 824 } 825 826 @Override 827 public void setExcludes(List<String> excludes) { 828 this.excludes = excludes; 829 } 830 831 @Override 832 public File[] getSuiteXmlFiles() { 833 return suiteXmlFiles.clone(); 834 } 835 836 @Override 837 @SuppressWarnings("UnusedDeclaration") 838 public void setSuiteXmlFiles(File[] suiteXmlFiles) { 839 this.suiteXmlFiles = suiteXmlFiles.clone(); 840 } 841 842 @Override 843 public String getRunOrder() { 844 return runOrder; 845 } 846 847 @Override 848 @SuppressWarnings("UnusedDeclaration") 849 public void setRunOrder(String runOrder) { 850 this.runOrder = runOrder; 851 } 852 853 @Override 854 public Long getRunOrderRandomSeed() { 855 return runOrderRandomSeed; 856 } 857 858 @Override 859 public void setRunOrderRandomSeed(Long runOrderRandomSeed) { 860 this.runOrderRandomSeed = runOrderRandomSeed; 861 } 862 863 @Override 864 public String getRunOrderStatisticsFileChecksum() { 865 return runOrderStatisticsFileChecksum; 866 } 867 868 @Override 869 public void setRunOrderStatisticsFileChecksum(String runOrderStatisticsFileChecksum) { 870 this.runOrderStatisticsFileChecksum = runOrderStatisticsFileChecksum; 871 } 872 873 @Override 874 public File getIncludesFile() { 875 return includesFile; 876 } 877 878 @Override 879 public File getExcludesFile() { 880 return excludesFile; 881 } 882 883 @Override 884 protected boolean useModulePath() { 885 return useModulePath; 886 } 887 888 @Override 889 protected void setUseModulePath(boolean useModulePath) { 890 this.useModulePath = useModulePath; 891 } 892 893 @Override 894 protected final List<File> suiteXmlFiles() { 895 return hasSuiteXmlFiles() ? Arrays.asList(suiteXmlFiles) : Collections.<File>emptyList(); 896 } 897 898 @Override 899 protected final boolean hasSuiteXmlFiles() { 900 return suiteXmlFiles != null && suiteXmlFiles.length != 0; 901 } 902 903 @Override 904 protected final String[] getExcludedEnvironmentVariables() { 905 return excludedEnvironmentVariables == null ? new String[0] : excludedEnvironmentVariables; 906 } 907 908 void setExcludedEnvironmentVariables(String[] excludedEnvironmentVariables) { 909 this.excludedEnvironmentVariables = excludedEnvironmentVariables; 910 } 911 912 @Override 913 protected final String getEnableProcessChecker() { 914 return enableProcessChecker; 915 } 916 917 @Override 918 protected final ForkNodeFactory getForkNode() { 919 return forkNode; 920 } 921 922 @Override 923 protected void warnIfIllegalFailOnFlakeCount() throws MojoFailureException { 924 if (failOnFlakeCount < 0) { 925 throw new MojoFailureException("Parameter \"failOnFlakeCount\" should not be negative."); 926 } 927 if (failOnFlakeCount > 0 && rerunFailingTestsCount < 1) { 928 throw new MojoFailureException("\"failOnFlakeCount\" requires rerunFailingTestsCount to be at least 1."); 929 } 930 } 931 932 @Override 933 protected void addPluginSpecificChecksumItems(ChecksumCalculator checksum) { 934 checksum.add(skipAfterFailureCount); 935 } 936 937 public String[] getIncludeJUnit5Engines() { 938 return includeJUnit5Engines; 939 } 940 941 @SuppressWarnings("UnusedDeclaration") 942 public void setIncludeJUnit5Engines(String[] includeJUnit5Engines) { 943 this.includeJUnit5Engines = includeJUnit5Engines; 944 } 945 946 public String[] getExcludeJUnit5Engines() { 947 return excludeJUnit5Engines; 948 } 949 950 @SuppressWarnings("UnusedDeclaration") 951 public void setExcludeJUnit5Engines(String[] excludeJUnit5Engines) { 952 this.excludeJUnit5Engines = excludeJUnit5Engines; 953 } 954 }