22
22
import org .apache .maven .plugins .annotations .Mojo ;
23
23
import org .apache .maven .plugins .annotations .Parameter ;
24
24
import org .apache .maven .plugins .annotations .ResolutionScope ;
25
- import org .apache .maven .surefire .suite .RunResult ;
25
+ import org .apache .maven .surefire .api .suite .RunResult ;
26
+ import org .apache .maven .surefire .extensions .ForkNodeFactory ;
26
27
27
28
/**
28
29
* Runs the project's tests with the specific setup needed for {@code GWTTestCase} tests.
@@ -288,8 +289,8 @@ public String[] getAdditionalClasspathElements() {
288
289
* Set this to "true" to cause a failure if the none of the tests specified in -Dtest=... are run. Defaults to
289
290
* "true".
290
291
*/
291
- @ Parameter (property = "surefire.failIfNoSpecifiedTests" )
292
- private Boolean failIfNoSpecifiedTests ;
292
+ @ Parameter (property = "surefire.failIfNoSpecifiedTests" , defaultValue = "true" )
293
+ private boolean failIfNoSpecifiedTests ;
293
294
294
295
/**
295
296
* Attach a debugger to the forked JVM. If set to "true", the process will suspend and wait for a debugger to attach
@@ -366,6 +367,33 @@ public String[] getAdditionalClasspathElements() {
366
367
@ Parameter
367
368
private List <String > includes ;
368
369
370
+ /**
371
+ * A list of {@literal <exclude>} elements specifying the tests (by pattern) that should be excluded in testing.
372
+ * When not specified and when the {@code test} parameter is not specified, the default excludes will be <br>
373
+ * <pre><code>
374
+ * {@literal <excludes>}
375
+ * {@literal <exclude>}**{@literal /}*$*{@literal </exclude>}
376
+ * {@literal </excludes>}
377
+ * </code></pre>
378
+ * (which excludes all inner classes).
379
+ * <br>
380
+ * This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified.
381
+ * <br>
382
+ * Each exclude item may also contain a comma-separated sub-list of items, which will be treated as multiple
383
+ * {@literal <exclude>} entries.<br>
384
+ * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
385
+ * <pre><code>
386
+ * {@literal <exclude>}%regex[pkg.*Slow.*.class], Unstable*{@literal </exclude>}
387
+ * </code></pre>
388
+ * <br>
389
+ * <b>Notice that</b> these values are relative to the directory containing generated test classes of the project
390
+ * being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults
391
+ * to the POM property <code>${project.build.testOutputDirectory}</code>, typically
392
+ * <code>{@literal src/test/java}</code> unless overridden.
393
+ */
394
+ @ Parameter (property = "surefire.excludes" )
395
+ private List <String > excludes ;
396
+
369
397
/**
370
398
* (JUnit 4+ providers)
371
399
* The number of times each failing test will be rerun. If set larger than 0, rerun failing tests immediately after
@@ -375,6 +403,13 @@ public String[] getAdditionalClasspathElements() {
375
403
@ Parameter (property = "surefire.rerunFailingTestsCount" , defaultValue = "0" )
376
404
private int rerunFailingTestsCount ;
377
405
406
+ /**
407
+ * Set this to a value greater than 0 to fail the whole test set if the cumulative number of flakes reaches
408
+ * this threshold. Set to 0 to allow an unlimited number of flakes.
409
+ */
410
+ @ Parameter (property = "surefire.failOnFlakeCount" , defaultValue = "0" )
411
+ private int failOnFlakeCount ;
412
+
378
413
/**
379
414
* (TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note that
380
415
* <code>suiteXmlFiles</code> is incompatible with several other parameters of this plugin, like
@@ -410,6 +445,20 @@ public String[] getAdditionalClasspathElements() {
410
445
@ Parameter (property = "surefire.runOrder" , defaultValue = "filesystem" )
411
446
private String runOrder ;
412
447
448
+ /**
449
+ * Sets the random seed that will be used to order the tests if {@code surefire.runOrder} is set to {@code random}.
450
+ * <br>
451
+ * <br>
452
+ * If no seeds are set and {@code surefire.runOrder} is set to {@code random}, then the seed used will be
453
+ * outputted (search for "To reproduce ordering use flag -Dsurefire.runOrder.random.seed").
454
+ * <br>
455
+ * <br>
456
+ * To deterministically reproduce any random test order that was run before, simply set the seed to
457
+ * be the same value.
458
+ */
459
+ @ Parameter (property = "surefire.runOrder.random.seed" )
460
+ private Long runOrderRandomSeed ;
461
+
413
462
/**
414
463
* A file containing include patterns. Blank lines, or lines starting with # are ignored. If {@code includes} are
415
464
* also specified, these patterns are appended. Example with path, simple and regex includes:<br/>
@@ -453,6 +502,85 @@ public String[] getAdditionalClasspathElements() {
453
502
@ Parameter (property = "surefire.shutdown" , defaultValue = "testset" )
454
503
private String shutdown ;
455
504
505
+ /**
506
+ * This parameter configures the forked node. Currently, you can select the communication protocol, i.e. process
507
+ * pipes or TCP/IP sockets.
508
+ * <br>
509
+ * See the documentation for more details:<br>
510
+ * <a href="https://maven.apache.org/plugins/maven-surefire-plugin/examples/process-communication.html">
511
+ * https://maven.apache.org/plugins/maven-surefire-plugin/examples/process-communication.html</a>
512
+ */
513
+ @ Parameter (property = "surefire.forkNode" )
514
+ private ForkNodeFactory forkNode ;
515
+
516
+ /**
517
+ * You can selectively exclude individual environment variables by enumerating their keys.
518
+ * <br>
519
+ * The environment is a system-dependent mapping from keys to values which is inherited from the Maven process
520
+ * to the forked Surefire processes. The keys must literally (case sensitive) match in order to exclude
521
+ * their environment variable.
522
+ * <br>
523
+ * Example to exclude three environment variables:
524
+ * <br>
525
+ * <i>mvn test -Dsurefire.excludedEnvironmentVariables=ACME1,ACME2,ACME3</i>
526
+ */
527
+ @ Parameter (property = "surefire.excludedEnvironmentVariables" )
528
+ private String [] excludedEnvironmentVariables ;
529
+
530
+ /**
531
+ * The process checkers are disabled by default.
532
+ * You can enable them namely by setting {@code ping} and {@code native} or {@code all} in this parameter.
533
+ * <br>
534
+ * The checker is useful in situations when you kill the build on a CI system and you want the Surefire forked JVM
535
+ * to kill the tests asap and free all handlers on the file system been previously used by the JVM and by the tests.
536
+ *
537
+ * <br>
538
+ *
539
+ * The {@code ping} should be safely used together with ZGC or Shenandoah Garbage Collector.
540
+ * Due to the {@code ping} relies on timing of the PING (triggered every 30 seconds), slow GCs may pause
541
+ * the timers and pretend that the parent process of the forked JVM does not exist.
542
+ *
543
+ * <br>
544
+ *
545
+ * The {@code native} is very fast checker.
546
+ * It is useful mechanism on Unix based systems, Linux distributions and Alpine/BusyBox Linux.
547
+ * See the JIRA <a href="https://issues.apache.org/jira/browse/SUREFIRE-1631">SUREFIRE-1631</a> for Windows issues.
548
+ *
549
+ * <br>
550
+ *
551
+ * Another useful configuration parameter is {@code forkedProcessTimeoutInSeconds}.
552
+ * <br>
553
+ * See the Frequently Asked Questions page with more details:<br>
554
+ * <a href="http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#kill-jvm">
555
+ * http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#kill-jvm</a>
556
+ * <br>
557
+ * <a href="http://maven.apache.org/surefire/maven-failsafe-plugin/faq.html#kill-jvm">
558
+ * http://maven.apache.org/surefire/maven-failsafe-plugin/faq.html#kill-jvm</a>
559
+ *
560
+ * <br>
561
+ *
562
+ * Example of use:
563
+ * <br>
564
+ * <i>mvn test -Dsurefire.enableProcessChecker=all</i>
565
+ */
566
+ @ Parameter (property = "surefire.enableProcessChecker" )
567
+ private String enableProcessChecker ;
568
+
569
+ @ Parameter (property = "surefire.systemPropertiesFile" )
570
+ private File systemPropertiesFile ;
571
+
572
+ /**
573
+ * Provide the ID/s of an JUnit engine to be included in the test run.
574
+ */
575
+ @ Parameter (property = "surefire.includeJUnit5Engines" )
576
+ private String [] includeJUnit5Engines ;
577
+
578
+ /**
579
+ * Provide the ID/s of an JUnit engine to be excluded in the test run.
580
+ */
581
+ @ Parameter (property = "surefire.excludeJUnit5Engines" )
582
+ private String [] excludeJUnit5Engines ;
583
+
456
584
/**
457
585
* The character encoding scheme to be applied while generating test report
458
586
* files (see target/surefire-reports/yourTestName.txt).
@@ -468,6 +596,16 @@ public int getRerunFailingTestsCount() {
468
596
return rerunFailingTestsCount ;
469
597
}
470
598
599
+ @ Override
600
+ public int getFailOnFlakeCount () {
601
+ return failOnFlakeCount ;
602
+ }
603
+
604
+ @ Override
605
+ public void setFailOnFlakeCount (int failOnFlakeCount ) {
606
+ this .failOnFlakeCount = failOnFlakeCount ;
607
+ }
608
+
471
609
@ Override
472
610
protected void handleSummary (RunResult summary , Exception firstForkException )
473
611
throws MojoExecutionException , MojoFailureException {
@@ -509,6 +647,16 @@ public void setIncludes(List<String> includes) {
509
647
this .includes = includes ;
510
648
}
511
649
650
+ @ Override
651
+ public List <String > getExcludes () {
652
+ return excludes ;
653
+ }
654
+
655
+ @ Override
656
+ public void setExcludes (List <String > excludes ) {
657
+ this .excludes = excludes ;
658
+ }
659
+
512
660
@ Override
513
661
protected String getReportSchemaLocation () {
514
662
return "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" ;
@@ -575,12 +723,12 @@ public void setTestClassesDirectory(File testClassesDirectory) {
575
723
}
576
724
577
725
@ Override
578
- public File getClassesDirectory () {
726
+ public File getMainBuildPath () {
579
727
return classesDirectory ;
580
728
}
581
729
582
730
@ Override
583
- public void setClassesDirectory (File classesDirectory ) {
731
+ public void setMainBuildPath (File classesDirectory ) {
584
732
this .classesDirectory = classesDirectory ;
585
733
}
586
734
@@ -614,6 +762,53 @@ public String getShutdown() {
614
762
return shutdown ;
615
763
}
616
764
765
+ @ Override
766
+ public String [] getExcludedEnvironmentVariables () {
767
+ return excludedEnvironmentVariables ;
768
+ }
769
+
770
+ @ Override
771
+ protected String getEnableProcessChecker () {
772
+ return enableProcessChecker ;
773
+ }
774
+
775
+ @ Override
776
+ protected ForkNodeFactory getForkNode () {
777
+ return forkNode ;
778
+ }
779
+
780
+ @ Override
781
+ public File getSystemPropertiesFile () {
782
+ return systemPropertiesFile ;
783
+ }
784
+
785
+ @ Override
786
+ public void setSystemPropertiesFile (File systemPropertiesFile ) {
787
+ this .systemPropertiesFile = systemPropertiesFile ;
788
+ }
789
+
790
+ @ Override
791
+ public String [] getIncludeJUnit5Engines () {
792
+ return includeJUnit5Engines ;
793
+ }
794
+
795
+ @ Override
796
+ public void setIncludeJUnit5Engines (String [] includeJUnit5Engines ) {
797
+ this .includeJUnit5Engines = includeJUnit5Engines ;
798
+ }
799
+
800
+
801
+ @ Override
802
+ public String [] getExcludeJUnit5Engines () {
803
+ return excludeJUnit5Engines ;
804
+ }
805
+
806
+
807
+ @ Override
808
+ public void setExcludeJUnit5Engines (String [] excludeJUnit5Engines ) {
809
+ this .excludeJUnit5Engines = excludeJUnit5Engines ;
810
+ }
811
+
617
812
@ Override
618
813
public boolean isPrintSummary () {
619
814
return printSummary ;
@@ -697,7 +892,7 @@ public void setUseManifestOnlyJar(boolean useManifestOnlyJar) {
697
892
}
698
893
699
894
@ Override
700
- public Boolean getFailIfNoSpecifiedTests () {
895
+ public boolean getFailIfNoSpecifiedTests () {
701
896
return failIfNoSpecifiedTests ;
702
897
}
703
898
@@ -756,6 +951,16 @@ public void setRunOrder(String runOrder) {
756
951
this .runOrder = runOrder ;
757
952
}
758
953
954
+ @ Override
955
+ public Long getRunOrderRandomSeed () {
956
+ return runOrderRandomSeed ;
957
+ }
958
+
959
+ @ Override
960
+ public void setRunOrderRandomSeed (Long runOrderRandomSeed ) {
961
+ this .runOrderRandomSeed = runOrderRandomSeed ;
962
+ }
963
+
759
964
@ Override
760
965
public File getIncludesFile () {
761
966
return includesFile ;
@@ -766,6 +971,17 @@ public File getExcludesFile() {
766
971
return excludesFile ;
767
972
}
768
973
974
+ @ Override
975
+ protected boolean useModulePath () {
976
+ // GWTTestCase must not use the module path
977
+ return false ;
978
+ }
979
+
980
+ @ Override
981
+ protected void setUseModulePath (boolean useModulePath ) {
982
+ throw new UnsupportedOperationException ("useModulePath is read-only" );
983
+ }
984
+
769
985
@ Override
770
986
protected List <File > suiteXmlFiles () {
771
987
return hasSuiteXmlFiles () ? Arrays .asList ( suiteXmlFiles ) : Collections .<File >emptyList ();
0 commit comments