Coverage Report - org.apache.maven.plugin.surefire.SurefirePlugin
 
Classes in this File Line Coverage Branch Coverage Complexity
SurefirePlugin
0%
0/220
0%
0/28
1.111
 
 1  
 package org.apache.maven.plugin.surefire;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *     http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.io.File;
 23  
 import java.util.HashMap;
 24  
 import java.util.Iterator;
 25  
 import java.util.List;
 26  
 import java.util.Map;
 27  
 import java.util.Properties;
 28  
 
 29  
 import org.apache.maven.artifact.factory.ArtifactFactory;
 30  
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 31  
 import org.apache.maven.artifact.repository.ArtifactRepository;
 32  
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 33  
 import org.apache.maven.execution.MavenSession;
 34  
 import org.apache.maven.plugin.MojoExecutionException;
 35  
 import org.apache.maven.plugin.MojoFailureException;
 36  
 import org.apache.maven.plugin.surefire.booterclient.ChecksumCalculator;
 37  
 import org.apache.maven.plugin.surefire.booterclient.ForkConfiguration;
 38  
 import org.apache.maven.plugin.surefire.booterclient.ForkStarter;
 39  
 import org.apache.maven.project.MavenProject;
 40  
 import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
 41  
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
 42  
 import org.apache.maven.surefire.booter.SurefireExecutionException;
 43  
 import org.apache.maven.toolchain.ToolchainManager;
 44  
 import org.codehaus.plexus.util.StringUtils;
 45  
 
 46  
 /**
 47  
  * Run tests using Surefire.
 48  
  *
 49  
  * @author Jason van Zyl
 50  
  * @version $Id: SurefirePlugin.java 1074633 2011-02-25 17:02:32Z olamy $
 51  
  * @requiresDependencyResolution test
 52  
  * @goal test
 53  
  * @phase test
 54  
  * @threadSafe
 55  
  * @noinspection JavaDoc
 56  
  */
 57  0
 public class SurefirePlugin
 58  
     extends AbstractSurefireMojo
 59  
     implements SurefireReportParameters
 60  
 {
 61  
 
 62  
     /**
 63  
      * Set this to "true" to skip running tests, but still compile them. Its use is NOT RECOMMENDED, but quite
 64  
      * convenient on occasion.
 65  
      *
 66  
      * @parameter default-value="false" expression="${skipTests}"
 67  
      * @since 2.4
 68  
      */
 69  
     private boolean skipTests;
 70  
 
 71  
     /**
 72  
      * This old parameter is just like <code>skipTests</code>, but bound to the old property "maven.test.skip.exec".
 73  
      *
 74  
      * @parameter expression="${maven.test.skip.exec}"
 75  
      * @since 2.3
 76  
      * @deprecated Use skipTests instead.
 77  
      */
 78  
     private boolean skipExec;
 79  
 
 80  
     /**
 81  
      * Set this to "true" to bypass unit tests entirely. Its use is NOT RECOMMENDED, especially if you
 82  
      * enable it using the "maven.test.skip" property, because maven.test.skip disables both running the
 83  
      * tests and compiling the tests.  Consider using the <code>skipTests</code> parameter instead.
 84  
      *
 85  
      * @parameter default-value="false" expression="${maven.test.skip}"
 86  
      */
 87  
     private boolean skip;
 88  
 
 89  
     /**
 90  
      * Set this to "true" to ignore a failure during testing. Its use is NOT RECOMMENDED, but quite convenient on
 91  
      * occasion.
 92  
      *
 93  
      * @parameter default-value="false" expression="${maven.test.failure.ignore}"
 94  
      */
 95  
     private boolean testFailureIgnore;
 96  
 
 97  
     /**
 98  
      * The base directory of the project being tested. This can be obtained in your unit test via
 99  
      * System.getProperty("basedir").
 100  
      *
 101  
      * @parameter default-value="${basedir}"
 102  
      */
 103  
     private File basedir;
 104  
 
 105  
     /**
 106  
      * The directory containing generated test classes of the project being tested.
 107  
      * This will be included at the beginning of the test classpath.                                                                                                                            *
 108  
      *
 109  
      * @parameter default-value="${project.build.testOutputDirectory}"
 110  
      */
 111  
     private File testClassesDirectory;
 112  
 
 113  
     /**
 114  
      * The directory containing generated classes of the project being tested.
 115  
      * This will be included after the test classes in the test classpath.
 116  
      *
 117  
      * @parameter default-value="${project.build.outputDirectory}"
 118  
      */
 119  
     private File classesDirectory;
 120  
 
 121  
     /**
 122  
      * The Maven Project Object.
 123  
      *
 124  
      * @parameter default-value="${project}"
 125  
      * @readonly
 126  
      */
 127  
     private MavenProject project;
 128  
 
 129  
     /**
 130  
      * List of dependencies to exclude from the test classpath.
 131  
      * Each dependency string must follow the format <i>groupId:artifactId</i>.
 132  
      * For example: <i>org.acme:project-a</i>
 133  
      *
 134  
      * @parameter
 135  
      * @since 2.6
 136  
      */
 137  
     private List classpathDependencyExcludes;
 138  
 
 139  
     /**
 140  
      * A dependency scope to exclude from the test classpath.
 141  
      * The scope can be one of the following scopes:
 142  
      * <p/>
 143  
      * <ul><li><i>compile</i> - system, provided, compile
 144  
      * <li><i>runtime</i> - compile, runtime
 145  
      * <li><i>test</i> - system, provided, compile, runtime, test</ul>
 146  
      *
 147  
      * @parameter default-value=""
 148  
      * @since 2.6
 149  
      */
 150  
     private String classpathDependencyScopeExclude;
 151  
 
 152  
     /**
 153  
      * Additional elements to be appended to the classpath.
 154  
      *
 155  
      * @parameter
 156  
      * @since 2.4
 157  
      */
 158  
     private List additionalClasspathElements;
 159  
 
 160  
     /**
 161  
      * Base directory where all reports are written to.
 162  
      *
 163  
      * @parameter default-value="${project.build.directory}/surefire-reports"
 164  
      */
 165  
     private File reportsDirectory;
 166  
 
 167  
     /**
 168  
      * The test source directory containing test class sources.
 169  
      *
 170  
      * @parameter default-value="${project.build.testSourceDirectory}"
 171  
      * @required
 172  
      * @since 2.2
 173  
      */
 174  
     private File testSourceDirectory;
 175  
 
 176  
     /**
 177  
      * Specify this parameter to run individual tests by file name, overriding the <code>includes/excludes</code>
 178  
      * parameters.  Each pattern you specify here will be used to create an
 179  
      * include pattern formatted like <code>**&#47;${test}.java</code>, so you can just type "-Dtest=MyTest"
 180  
      * to run a single test called "foo/MyTest.java".<br/>
 181  
      * This parameter overrides the <code>includes/excludes</code> parameters, and the TestNG
 182  
      * <code>suiteXmlFiles</code> parameter.
 183  
      * 
 184  
      * since 2.7.3
 185  
      * You can execute a limited number of method in the test with adding #myMethod or #my*ethod.
 186  
      * Si type "-Dtest=MyTest#myMethod"
 187  
      * <b>supported for junit 4.x and testNg</b>
 188  
      * 
 189  
      * @parameter expression="${test}"
 190  
      */
 191  
     private String test;
 192  
 
 193  
     /**
 194  
      * A list of &lt;include> elements specifying the tests (by pattern) that should be included in testing. When not
 195  
      * specified and when the <code>test</code> parameter is not specified, the default includes will be
 196  
      * <code><br/>
 197  
      * &lt;includes><br/>
 198  
      * &nbsp;&lt;include>**&#47;Test*.java&lt;/include><br/>
 199  
      * &nbsp;&lt;include>**&#47;*Test.java&lt;/include><br/>
 200  
      * &nbsp;&lt;include>**&#47;*TestCase.java&lt;/include><br/>
 201  
      * &lt;/includes><br/>
 202  
      * </code>
 203  
      * This parameter is ignored if the TestNG <code>suiteXmlFiles</code> parameter is specified.
 204  
      *
 205  
      * @parameter
 206  
      */
 207  
     private List includes;
 208  
 
 209  
     /**
 210  
      * A list of &lt;exclude> elements specifying the tests (by pattern) that should be excluded in testing. When not
 211  
      * specified and when the <code>test</code> parameter is not specified, the default excludes will be
 212  
      * <code><br/>
 213  
      * &lt;excludes><br/>
 214  
      * &nbsp;&lt;exclude>**&#47;*$*&lt;/exclude><br/>
 215  
      * &lt;/excludes><br/>
 216  
      * </code>
 217  
      * (which excludes all inner classes).<br>
 218  
      * This parameter is ignored if the TestNG <code>suiteXmlFiles</code> parameter is specified.
 219  
      *
 220  
      * @parameter
 221  
      */
 222  
     private List excludes;
 223  
 
 224  
     /**
 225  
      * ArtifactRepository of the localRepository. To obtain the directory of localRepository in unit tests use
 226  
      * System.getProperty("localRepository").
 227  
      *
 228  
      * @parameter expression="${localRepository}"
 229  
      * @required
 230  
      * @readonly
 231  
      */
 232  
     private ArtifactRepository localRepository;
 233  
 
 234  
     /**
 235  
      * List of System properties to pass to the JUnit tests.
 236  
      *
 237  
      * @parameter
 238  
      * @deprecated Use systemPropertyVariables instead.
 239  
      */
 240  
     private Properties systemProperties;
 241  
 
 242  
     /**
 243  
      * List of System properties to pass to the JUnit tests.
 244  
      *
 245  
      * @parameter
 246  
      * @since 2.5
 247  
      */
 248  
     private Map systemPropertyVariables;
 249  
 
 250  
     /**
 251  
      * List of properties for configuring all TestNG related configurations. This is the new
 252  
      * preferred method of configuring TestNG.
 253  
      *
 254  
      * @parameter
 255  
      * @since 2.4
 256  
      */
 257  
     private Properties properties;
 258  
 
 259  
     /**
 260  
      * Map of plugin artifacts.
 261  
      *
 262  
      * @parameter expression="${plugin.artifactMap}"
 263  
      * @required
 264  
      * @readonly
 265  
      */
 266  
     private Map pluginArtifactMap;
 267  
 
 268  
     /**
 269  
      * Map of project artifacts.
 270  
      *
 271  
      * @parameter expression="${project.artifactMap}"
 272  
      * @required
 273  
      * @readonly
 274  
      */
 275  
     private Map projectArtifactMap;
 276  
 
 277  
     /**
 278  
      * Option to print summary of test suites or just print the test cases that have errors.
 279  
      *
 280  
      * @parameter expression="${surefire.printSummary}" default-value="true"
 281  
      */
 282  
     private boolean printSummary;
 283  
 
 284  
     /**
 285  
      * Selects the formatting for the test report to be generated. Can be set as "brief" or "plain".
 286  
      *
 287  
      * @parameter expression="${surefire.reportFormat}" default-value="brief"
 288  
      */
 289  
     private String reportFormat;
 290  
 
 291  
     /**
 292  
      * Option to generate a file test report or just output the test report to the console.
 293  
      *
 294  
      * @parameter expression="${surefire.useFile}" default-value="true"
 295  
      */
 296  
     private boolean useFile;
 297  
 
 298  
     /**
 299  
      * When forking, set this to "true" to redirect the unit test standard output to a file (found in
 300  
      * reportsDirectory/testName-output.txt).
 301  
      *
 302  
      * @parameter expression="${maven.test.redirectTestOutputToFile}" default-value="false"
 303  
      * @since 2.3
 304  
      */
 305  
     private boolean redirectTestOutputToFile;
 306  
 
 307  
     /**
 308  
      * Set this to "true" to cause a failure if there are no tests to run. Defaults to "false".
 309  
      *
 310  
      * @parameter expression="${failIfNoTests}"
 311  
      * @since 2.4
 312  
      */
 313  
     private Boolean failIfNoTests;
 314  
 
 315  
     /**
 316  
      * Option to specify the forking mode. Can be "never", "once" or "always". "none" and "pertest" are also accepted
 317  
      * for backwards compatibility. "always" forks for each test-class.
 318  
      *
 319  
      * @parameter expression="${forkMode}" default-value="once"
 320  
      * @since 2.1
 321  
      */
 322  
     private String forkMode;
 323  
 
 324  
     /**
 325  
      * Option to specify the jvm (or path to the java executable) to use with the forking options. For the default, the
 326  
      * jvm will be a new instance of the same VM as the one used to run Maven. JVM settings are not inherited from
 327  
      * MAVEN_OPTS.
 328  
      *
 329  
      * @parameter expression="${jvm}"
 330  
      * @since 2.1
 331  
      */
 332  
     private String jvm;
 333  
 
 334  
     /**
 335  
      * Arbitrary JVM options to set on the command line.
 336  
      *
 337  
      * @parameter expression="${argLine}"
 338  
      * @since 2.1
 339  
      */
 340  
     private String argLine;
 341  
 
 342  
     /**
 343  
      * Attach a debugger to the forked JVM.  If set to "true", the process will suspend and
 344  
      * wait for a debugger to attach on port 5005.  If set to some other string, that
 345  
      * string will be appended to the argLine, allowing you to configure arbitrary
 346  
      * debuggability options (without overwriting the other options specified through the <code>argLine</code>
 347  
      * parameter).
 348  
      *
 349  
      * @parameter expression="${maven.surefire.debug}"
 350  
      * @since 2.4
 351  
      */
 352  
     private String debugForkedProcess;
 353  
 
 354  
     /**
 355  
      * Kill the forked test process after a certain number of seconds.  If set to 0,
 356  
      * wait forever for the process, never timing out.
 357  
      *
 358  
      * @parameter expression="${surefire.timeout}"
 359  
      * @since 2.4
 360  
      */
 361  
     private int forkedProcessTimeoutInSeconds;
 362  
 
 363  
     /**
 364  
      * Additional environment variables to set on the command line.
 365  
      *
 366  
      * @parameter
 367  
      * @since 2.1.3
 368  
      */
 369  0
     private Map environmentVariables = new HashMap();
 370  
 
 371  
     /**
 372  
      * Command line working directory.
 373  
      *
 374  
      * @parameter expression="${basedir}"
 375  
      * @since 2.1.3
 376  
      */
 377  
     private File workingDirectory;
 378  
 
 379  
     /**
 380  
      * When false it makes tests run using the standard classloader delegation instead of the default Maven isolated
 381  
      * classloader. Only used when forking (forkMode is not "none").<br/> Setting it to false helps with some problems
 382  
      * caused by conflicts between xml parsers in the classpath and the Java 5 provider parser.
 383  
      *
 384  
      * @parameter expression="${childDelegation}" default-value="false"
 385  
      * @since 2.1
 386  
      */
 387  
     private boolean childDelegation;
 388  
 
 389  
     /**
 390  
      * (TestNG only) Groups for this test. Only classes/methods/etc decorated with one of the groups specified here will be included
 391  
      * in test run, if specified.<br/>
 392  
      * This parameter is ignored if the <code>suiteXmlFiles</code> parameter is specified.
 393  
      *
 394  
      * @parameter expression="${groups}"
 395  
      * @since 2.2
 396  
      */
 397  
     private String groups;
 398  
 
 399  
     /**
 400  
      * (TestNG only) Excluded groups. Any methods/classes/etc with one of the groups specified in this list will specifically not be
 401  
      * run.<br/>
 402  
      * This parameter is ignored if the <code>suiteXmlFiles</code> parameter is specified.
 403  
      *
 404  
      * @parameter expression="${excludedGroups}"
 405  
      * @since 2.2
 406  
      */
 407  
     private String excludedGroups;
 408  
 
 409  
     /**
 410  
      * (TestNG only) List of &lt;suiteXmlFile> elements specifying TestNG suite xml file locations. Note that <code>suiteXmlFiles</code> is incompatible
 411  
      * with several other parameters of this plugin, like <code>includes/excludes</code>.<br/>
 412  
      * This parameter is ignored if the <code>test</code> parameter is specified (allowing you to run a single
 413  
      * test instead of an entire suite).
 414  
      *
 415  
      * @parameter
 416  
      * @since 2.2
 417  
      */
 418  
     private File[] suiteXmlFiles;
 419  
 
 420  
     /**
 421  
      * Allows you to specify the name of the JUnit artifact. If not set, <code>junit:junit</code> will be used.
 422  
      *
 423  
      * @parameter expression="${junitArtifactName}" default-value="junit:junit"
 424  
      * @since 2.3.1
 425  
      */
 426  
     private String junitArtifactName;
 427  
 
 428  
     /**
 429  
      * Allows you to specify the name of the TestNG artifact. If not set, <code>org.testng:testng</code> will be used.
 430  
      *
 431  
      * @parameter expression="${testNGArtifactName}" default-value="org.testng:testng"
 432  
      * @since 2.3.1
 433  
      */
 434  
     private String testNGArtifactName;
 435  
 
 436  
     /**
 437  
      * (TestNG/JUnit 4.7 provider only) The attribute thread-count allows you to specify how many threads should be allocated for this execution. Only
 438  
      * makes sense to use in conjunction with the <code>parallel</code> parameter.
 439  
      *
 440  
      * @parameter expression="${threadCount}"
 441  
      * @since 2.2
 442  
      */
 443  
     private int threadCount;
 444  
 
 445  
     /**
 446  
      * (JUnit 4.7 provider) Indicates that threadCount is per cpu core.
 447  
      *
 448  
      * @parameter expression="${perCoreThreadCount}" default-value="true"
 449  
      * @since 2.5
 450  
      */
 451  
     private boolean perCoreThreadCount;
 452  
 
 453  
     /**
 454  
      * (JUnit 4.7 provider) Indicates that the thread pool will be unlimited. The <code>parallel</code> parameter and the actual number of classes/methods
 455  
      * will decide. Setting this to "true" effectively disables <code>perCoreThreadCount</code> and <code>threadCount</code>. Defaults to "false".
 456  
      *
 457  
      * @parameter expression="${useUnlimitedThreads}" default-value="false"
 458  
      * @since 2.5
 459  
      */
 460  
     private boolean useUnlimitedThreads;
 461  
 
 462  
     /**
 463  
      * (TestNG only) When you use the <code>parallel</code> attribute, TestNG will try to run all your test methods in separate threads, except for
 464  
      * methods that depend on each other, which will be run in the same thread in order to respect their order of
 465  
      * execution.
 466  
      * <p/>
 467  
      * (JUnit 4.7 provider) Supports values "classes"/"methods"/"both" to run in separate threads, as controlled by <code>threadCount</code>.
 468  
      *
 469  
      * @parameter expression="${parallel}"
 470  
      * @since 2.2
 471  
      */
 472  
     private String parallel;
 473  
 
 474  
     /**
 475  
      * Whether to trim the stack trace in the reports to just the lines within the test, or show the full trace.
 476  
      *
 477  
      * @parameter expression="${trimStackTrace}" default-value="true"
 478  
      * @since 2.2
 479  
      */
 480  
     private boolean trimStackTrace;
 481  
 
 482  
     /**
 483  
      * Resolves the artifacts needed.
 484  
      *
 485  
      * @component
 486  
      */
 487  
     private ArtifactResolver artifactResolver;
 488  
 
 489  
     /**
 490  
      * Creates the artifact.
 491  
      *
 492  
      * @component
 493  
      */
 494  
     private ArtifactFactory artifactFactory;
 495  
 
 496  
     /**
 497  
      * The remote plugin repositories declared in the POM.
 498  
      *
 499  
      * @parameter expression="${project.pluginArtifactRepositories}"
 500  
      * @since 2.2
 501  
      */
 502  
     private List remoteRepositories;
 503  
 
 504  
     /**
 505  
      * For retrieval of artifact's metadata.
 506  
      *
 507  
      * @component
 508  
      */
 509  
     private ArtifactMetadataSource metadataSource;
 510  
 
 511  
     private Properties originalSystemProperties;
 512  
 
 513  
     /**
 514  
      * systemPropertyVariables + systemProperties
 515  
      */
 516  0
     private Properties internalSystemProperties = new Properties();
 517  
 
 518  
     /**
 519  
      * Flag to disable the generation of report files in xml format.
 520  
      *
 521  
      * @parameter expression="${disableXmlReport}" default-value="false"
 522  
      * @since 2.2
 523  
      */
 524  
     private boolean disableXmlReport;
 525  
 
 526  
     /**
 527  
      * Option to pass dependencies to the system's classloader instead of using an isolated class loader when forking.
 528  
      * Prevents problems with JDKs which implement the service provider lookup mechanism by using the system's
 529  
      * classloader.
 530  
      *
 531  
      * @parameter expression="${surefire.useSystemClassLoader}" default-value="true"
 532  
      * @since 2.3
 533  
      */
 534  
     private boolean useSystemClassLoader;
 535  
 
 536  
     /**
 537  
      * By default, Surefire forks your tests using a manifest-only JAR; set this parameter
 538  
      * to "false" to force it to launch your tests with a plain old Java classpath.
 539  
      * (See http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html
 540  
      * for a more detailed explanation of manifest-only JARs and their benefits.)
 541  
      * <p/>
 542  
      * Beware, setting this to "false" may cause your tests to
 543  
      * fail on Windows if your classpath is too long.
 544  
      *
 545  
      * @parameter expression="${surefire.useManifestOnlyJar}" default-value="true"
 546  
      * @since 2.4.3
 547  
      */
 548  
     private boolean useManifestOnlyJar;
 549  
 
 550  
     /**
 551  
      * By default, Surefire enables JVM assertions for the execution of your test cases. To disable the assertions, set
 552  
      * this flag to "false".
 553  
      *
 554  
      * @parameter expression="${enableAssertions}" default-value="true"
 555  
      * @since 2.3.1
 556  
      */
 557  
     private boolean enableAssertions;
 558  
 
 559  
     /**
 560  
      * The current build session instance.
 561  
      *
 562  
      * @parameter expression="${session}"
 563  
      * @required
 564  
      * @readonly
 565  
      */
 566  
     private MavenSession session;
 567  
 
 568  
     /**
 569  
      * (TestNG only) Define the factory class used to create all test instances.
 570  
      *
 571  
      * @parameter expression="${objectFactory}"
 572  
      * @since 2.5
 573  
      */
 574  
     private String objectFactory;
 575  
 
 576  
 
 577  
     /**
 578  
      * @parameter default-value="${session.parallel}"
 579  
      * @readonly
 580  
      * @noinspection UnusedDeclaration
 581  
      */
 582  
     private Boolean parallelMavenExecution;
 583  
 
 584  
     /**
 585  
      * Defines the order the tests will be run in. Supported values are "alphabetical", "reversealphabetical",
 586  
      * "random", "hourly" (alphabetical on even hours, reverse alphabetical on odd hours) and "filesystem".<p/>
 587  
      * <p/>
 588  
      * Odd/Even for hourly is determined at the time the of scanning the classpath, meaning it could change during
 589  
      * a multi-module build.
 590  
      *
 591  
      * @parameter default-value="filesystem"
 592  
      * @since 2.7
 593  
      */
 594  
     private String runOrder;
 595  
 
 596  
     /**
 597  
      * @component
 598  
      */
 599  
     private ToolchainManager toolchainManager;
 600  
 
 601  
     public void executeAfterPreconditionsChecked()
 602  
         throws MojoExecutionException, MojoFailureException
 603  
     {
 604  0
         final List providers = initialize();
 605  0
         Exception exception = null;
 606  0
         ForkConfiguration forkConfiguration = null;
 607  0
         int result = 0;
 608  0
         for ( Iterator iter = providers.iterator(); iter.hasNext(); )
 609  
         {
 610  0
             ProviderInfo provider = (ProviderInfo) iter.next();
 611  0
             forkConfiguration = getForkConfiguration();
 612  0
             ClassLoaderConfiguration classLoaderConfiguration = getClassLoaderConfiguration( forkConfiguration );
 613  0
             ForkStarter forkStarter = createForkStarter( provider, forkConfiguration, classLoaderConfiguration );
 614  
 
 615  
             try
 616  
             {
 617  0
                 result = forkStarter.run();
 618  
             }
 619  0
             catch ( SurefireBooterForkException e )
 620  
             {
 621  0
                 exception = e;
 622  
             }
 623  0
             catch ( SurefireExecutionException e )
 624  
             {
 625  0
                 exception = e;
 626  0
             }
 627  0
         }
 628  
 
 629  0
         if ( exception != null )
 630  
         {
 631  0
             throw new MojoExecutionException( exception.getMessage(), exception );
 632  
         }
 633  
 
 634  0
         if ( getOriginalSystemProperties() != null && forkConfiguration != null && !forkConfiguration.isForking() )
 635  
         {
 636  
             // restore system properties, only makes sense when not forking..
 637  0
             System.setProperties( getOriginalSystemProperties() );
 638  
         }
 639  
 
 640  0
         writeSummary(result);
 641  0
     }
 642  
 
 643  
         private void writeSummary(int result) throws MojoFailureException {
 644  0
                 SurefireHelper.reportExecution( this, result, getLog() );
 645  0
         }
 646  
 
 647  
     protected boolean isSkipExecution()
 648  
     {
 649  0
             return isSkip() || isSkipTests() || isSkipExec();
 650  
     }
 651  
 
 652  
     protected String getPluginName()
 653  
     {
 654  0
         return "surefire";
 655  
     }
 656  
 
 657  
     protected String[] getDefaultIncludes()
 658  
     {
 659  0
         return new String[]{ "**/Test*.java", "**/*Test.java", "**/*TestCase.java" };
 660  
     }
 661  
 
 662  
     // now for the implementation of the field accessors
 663  
 
 664  
     public boolean isSkipTests()
 665  
     {
 666  0
         return skipTests;
 667  
     }
 668  
 
 669  
 
 670  
     public void setSkipTests( boolean skipTests )
 671  
     {
 672  0
         this.skipTests = skipTests;
 673  0
     }
 674  
 
 675  
     /**
 676  
      * @noinspection deprecation
 677  
      */
 678  
     public boolean isSkipExec()
 679  
     {
 680  0
         return skipExec;
 681  
     }
 682  
 
 683  
     /**
 684  
      * @noinspection deprecation
 685  
      */
 686  
     public void setSkipExec( boolean skipExec )
 687  
     {
 688  0
         this.skipExec = skipExec;
 689  0
     }
 690  
 
 691  
     public boolean isSkip()
 692  
     {
 693  0
         return skip;
 694  
     }
 695  
 
 696  
     public void setSkip( boolean skip )
 697  
     {
 698  0
         this.skip = skip;
 699  0
     }
 700  
 
 701  
     public boolean isTestFailureIgnore()
 702  
     {
 703  0
         return testFailureIgnore;
 704  
     }
 705  
 
 706  
     public void setTestFailureIgnore( boolean testFailureIgnore )
 707  
     {
 708  0
         this.testFailureIgnore = testFailureIgnore;
 709  0
     }
 710  
 
 711  
     public File getBasedir()
 712  
     {
 713  0
         return basedir;
 714  
     }
 715  
 
 716  
     public void setBasedir( File basedir )
 717  
     {
 718  0
         this.basedir = basedir;
 719  0
     }
 720  
 
 721  
     public File getTestClassesDirectory()
 722  
     {
 723  0
         return testClassesDirectory;
 724  
     }
 725  
 
 726  
     public void setTestClassesDirectory( File testClassesDirectory )
 727  
     {
 728  0
         this.testClassesDirectory = testClassesDirectory;
 729  0
     }
 730  
 
 731  
     public File getClassesDirectory()
 732  
     {
 733  0
         return classesDirectory;
 734  
     }
 735  
 
 736  
     public void setClassesDirectory( File classesDirectory )
 737  
     {
 738  0
         this.classesDirectory = classesDirectory;
 739  0
     }
 740  
 
 741  
     public MavenProject getProject()
 742  
     {
 743  0
         return project;
 744  
     }
 745  
 
 746  
     public void setProject( MavenProject project )
 747  
     {
 748  0
         this.project = project;
 749  0
     }
 750  
 
 751  
     public List getClasspathDependencyExcludes()
 752  
     {
 753  0
         return classpathDependencyExcludes;
 754  
     }
 755  
 
 756  
     public void setClasspathDependencyExcludes( List classpathDependencyExcludes )
 757  
     {
 758  0
         this.classpathDependencyExcludes = classpathDependencyExcludes;
 759  0
     }
 760  
 
 761  
     public String getClasspathDependencyScopeExclude()
 762  
     {
 763  0
         return classpathDependencyScopeExclude;
 764  
     }
 765  
 
 766  
     public void setClasspathDependencyScopeExclude( String classpathDependencyScopeExclude )
 767  
     {
 768  0
         this.classpathDependencyScopeExclude = classpathDependencyScopeExclude;
 769  0
     }
 770  
 
 771  
     public List getAdditionalClasspathElements()
 772  
     {
 773  0
         return additionalClasspathElements;
 774  
     }
 775  
 
 776  
     public void setAdditionalClasspathElements( List additionalClasspathElements )
 777  
     {
 778  0
         this.additionalClasspathElements = additionalClasspathElements;
 779  0
     }
 780  
 
 781  
     public File getReportsDirectory()
 782  
     {
 783  0
         return reportsDirectory;
 784  
     }
 785  
 
 786  
     public void setReportsDirectory( File reportsDirectory )
 787  
     {
 788  0
         this.reportsDirectory = reportsDirectory;
 789  0
     }
 790  
 
 791  
     public File getTestSourceDirectory()
 792  
     {
 793  0
         return testSourceDirectory;
 794  
     }
 795  
 
 796  
     public void setTestSourceDirectory( File testSourceDirectory )
 797  
     {
 798  0
         this.testSourceDirectory = testSourceDirectory;
 799  0
     }
 800  
 
 801  
     public String getTest()
 802  
     {
 803  0
         if ( StringUtils.isBlank( test ) )
 804  
         {
 805  0
             return null;
 806  
         }
 807  0
         int index = test.indexOf( '#' );
 808  0
         if ( index >= 0 )
 809  
         {
 810  0
             return test.substring( 0, index );
 811  
         }
 812  0
         return test;
 813  
     }
 814  
     
 815  
     /**
 816  
      * @since 2.7.3
 817  
      */
 818  
     public String getTestMethod()
 819  
     {
 820  0
         if ( StringUtils.isBlank( test ) )
 821  
         {
 822  0
             return null;
 823  
         }        
 824  0
         int index = this.test.indexOf( '#' );
 825  0
         if ( index >= 0 )
 826  
         {
 827  0
             return this.test.substring( index + 1, this.test.length() );
 828  
         }
 829  0
         return null;
 830  
     }    
 831  
     
 832  
 
 833  
     public void setTest( String test )
 834  
     {
 835  0
         this.test = test;
 836  0
     }
 837  
 
 838  
     public List getIncludes()
 839  
     {
 840  0
         return includes;
 841  
     }
 842  
 
 843  
     public void setIncludes( List includes )
 844  
     {
 845  0
         this.includes = includes;
 846  0
     }
 847  
 
 848  
     public List getExcludes()
 849  
     {
 850  0
         return excludes;
 851  
     }
 852  
 
 853  
     public void setExcludes( List excludes )
 854  
     {
 855  0
         this.excludes = excludes;
 856  0
     }
 857  
 
 858  
     public ArtifactRepository getLocalRepository()
 859  
     {
 860  0
         return localRepository;
 861  
     }
 862  
 
 863  
     public void setLocalRepository( ArtifactRepository localRepository )
 864  
     {
 865  0
         this.localRepository = localRepository;
 866  0
     }
 867  
 
 868  
     /**
 869  
      * @noinspection deprecation
 870  
      */
 871  
     public Properties getSystemProperties()
 872  
     {
 873  0
         return systemProperties;
 874  
     }
 875  
 
 876  
     /**
 877  
      * @noinspection deprecation
 878  
      */
 879  
     public void setSystemProperties( Properties systemProperties )
 880  
     {
 881  0
         this.systemProperties = systemProperties;
 882  0
     }
 883  
 
 884  
     public Map getSystemPropertyVariables()
 885  
     {
 886  0
         return systemPropertyVariables;
 887  
     }
 888  
 
 889  
     public void setSystemPropertyVariables( Map systemPropertyVariables )
 890  
     {
 891  0
         this.systemPropertyVariables = systemPropertyVariables;
 892  0
     }
 893  
 
 894  
     public Properties getProperties()
 895  
     {
 896  0
         return properties;
 897  
     }
 898  
 
 899  
     public void setProperties( Properties properties )
 900  
     {
 901  0
         this.properties = properties;
 902  0
     }
 903  
 
 904  
     public Map getPluginArtifactMap()
 905  
     {
 906  0
         return pluginArtifactMap;
 907  
     }
 908  
 
 909  
     public void setPluginArtifactMap( Map pluginArtifactMap )
 910  
     {
 911  0
         this.pluginArtifactMap = pluginArtifactMap;
 912  0
     }
 913  
 
 914  
     public Map getProjectArtifactMap()
 915  
     {
 916  0
         return projectArtifactMap;
 917  
     }
 918  
 
 919  
     public void setProjectArtifactMap( Map projectArtifactMap )
 920  
     {
 921  0
         this.projectArtifactMap = projectArtifactMap;
 922  0
     }
 923  
 
 924  
     public boolean isPrintSummary()
 925  
     {
 926  0
         return printSummary;
 927  
     }
 928  
 
 929  
     public void setPrintSummary( boolean printSummary )
 930  
     {
 931  0
         this.printSummary = printSummary;
 932  0
     }
 933  
 
 934  
     public String getReportFormat()
 935  
     {
 936  0
         return reportFormat;
 937  
     }
 938  
 
 939  
     public void setReportFormat( String reportFormat )
 940  
     {
 941  0
         this.reportFormat = reportFormat;
 942  0
     }
 943  
 
 944  
     public boolean isUseFile()
 945  
     {
 946  0
         return useFile;
 947  
     }
 948  
 
 949  
     public void setUseFile( boolean useFile )
 950  
     {
 951  0
         this.useFile = useFile;
 952  0
     }
 953  
 
 954  
     public boolean isRedirectTestOutputToFile()
 955  
     {
 956  0
         return redirectTestOutputToFile;
 957  
     }
 958  
 
 959  
     public void setRedirectTestOutputToFile( boolean redirectTestOutputToFile )
 960  
     {
 961  0
         this.redirectTestOutputToFile = redirectTestOutputToFile;
 962  0
     }
 963  
 
 964  
     public Boolean getFailIfNoTests()
 965  
     {
 966  0
         return failIfNoTests;
 967  
     }
 968  
 
 969  
     public void setFailIfNoTests( Boolean failIfNoTests )
 970  
     {
 971  0
         this.failIfNoTests = failIfNoTests;
 972  0
     }
 973  
 
 974  
     public String getForkMode()
 975  
     {
 976  0
         return forkMode;
 977  
     }
 978  
 
 979  
     public void setForkMode( String forkMode )
 980  
     {
 981  0
         this.forkMode = forkMode;
 982  0
     }
 983  
 
 984  
     public String getJvm()
 985  
     {
 986  0
         return jvm;
 987  
     }
 988  
 
 989  
     public void setJvm( String jvm )
 990  
     {
 991  0
         this.jvm = jvm;
 992  0
     }
 993  
 
 994  
     public String getArgLine()
 995  
     {
 996  0
         return argLine;
 997  
     }
 998  
 
 999  
     public void setArgLine( String argLine )
 1000  
     {
 1001  0
         this.argLine = argLine;
 1002  0
     }
 1003  
 
 1004  
     public String getDebugForkedProcess()
 1005  
     {
 1006  0
         return debugForkedProcess;
 1007  
     }
 1008  
 
 1009  
     public void setDebugForkedProcess( String debugForkedProcess )
 1010  
     {
 1011  0
         this.debugForkedProcess = debugForkedProcess;
 1012  0
     }
 1013  
 
 1014  
     public int getForkedProcessTimeoutInSeconds()
 1015  
     {
 1016  0
         return forkedProcessTimeoutInSeconds;
 1017  
     }
 1018  
 
 1019  
     public void setForkedProcessTimeoutInSeconds( int forkedProcessTimeoutInSeconds )
 1020  
     {
 1021  0
         this.forkedProcessTimeoutInSeconds = forkedProcessTimeoutInSeconds;
 1022  0
     }
 1023  
 
 1024  
     public Map getEnvironmentVariables()
 1025  
     {
 1026  0
         return environmentVariables;
 1027  
     }
 1028  
 
 1029  
     public void setEnvironmentVariables( Map environmentVariables )
 1030  
     {
 1031  0
         this.environmentVariables = environmentVariables;
 1032  0
     }
 1033  
 
 1034  
     public File getWorkingDirectory()
 1035  
     {
 1036  0
         return workingDirectory;
 1037  
     }
 1038  
 
 1039  
     public void setWorkingDirectory( File workingDirectory )
 1040  
     {
 1041  0
         this.workingDirectory = workingDirectory;
 1042  0
     }
 1043  
 
 1044  
     public boolean isChildDelegation()
 1045  
     {
 1046  0
         return childDelegation;
 1047  
     }
 1048  
 
 1049  
     public void setChildDelegation( boolean childDelegation )
 1050  
     {
 1051  0
         this.childDelegation = childDelegation;
 1052  0
     }
 1053  
 
 1054  
     public String getGroups()
 1055  
     {
 1056  0
         return groups;
 1057  
     }
 1058  
 
 1059  
     public void setGroups( String groups )
 1060  
     {
 1061  0
         this.groups = groups;
 1062  0
     }
 1063  
 
 1064  
     public String getExcludedGroups()
 1065  
     {
 1066  0
         return excludedGroups;
 1067  
     }
 1068  
 
 1069  
     public void setExcludedGroups( String excludedGroups )
 1070  
     {
 1071  0
         this.excludedGroups = excludedGroups;
 1072  0
     }
 1073  
 
 1074  
     public File[] getSuiteXmlFiles()
 1075  
     {
 1076  0
         return suiteXmlFiles;
 1077  
     }
 1078  
 
 1079  
     public void setSuiteXmlFiles( File[] suiteXmlFiles )
 1080  
     {
 1081  0
         this.suiteXmlFiles = suiteXmlFiles;
 1082  0
     }
 1083  
 
 1084  
     public String getJunitArtifactName()
 1085  
     {
 1086  0
         return junitArtifactName;
 1087  
     }
 1088  
 
 1089  
     public void setJunitArtifactName( String junitArtifactName )
 1090  
     {
 1091  0
         this.junitArtifactName = junitArtifactName;
 1092  0
     }
 1093  
 
 1094  
     public String getTestNGArtifactName()
 1095  
     {
 1096  0
         return testNGArtifactName;
 1097  
     }
 1098  
 
 1099  
     public void setTestNGArtifactName( String testNGArtifactName )
 1100  
     {
 1101  0
         this.testNGArtifactName = testNGArtifactName;
 1102  0
     }
 1103  
 
 1104  
     public int getThreadCount()
 1105  
     {
 1106  0
         return threadCount;
 1107  
     }
 1108  
 
 1109  
     public void setThreadCount( int threadCount )
 1110  
     {
 1111  0
         this.threadCount = threadCount;
 1112  0
     }
 1113  
 
 1114  
     public boolean getPerCoreThreadCount()
 1115  
     {
 1116  0
         return perCoreThreadCount;
 1117  
     }
 1118  
 
 1119  
     public void setPerCoreThreadCount( boolean perCoreThreadCount )
 1120  
     {
 1121  0
         this.perCoreThreadCount = perCoreThreadCount;
 1122  0
     }
 1123  
 
 1124  
     public boolean getUseUnlimitedThreads()
 1125  
     {
 1126  0
         return useUnlimitedThreads;
 1127  
     }
 1128  
 
 1129  
     public void setUseUnlimitedThreads( boolean useUnlimitedThreads )
 1130  
     {
 1131  0
         this.useUnlimitedThreads = useUnlimitedThreads;
 1132  0
     }
 1133  
 
 1134  
     public String getParallel()
 1135  
     {
 1136  0
         return parallel;
 1137  
     }
 1138  
 
 1139  
     public void setParallel( String parallel )
 1140  
     {
 1141  0
         this.parallel = parallel;
 1142  0
     }
 1143  
 
 1144  
     public boolean isTrimStackTrace()
 1145  
     {
 1146  0
         return trimStackTrace;
 1147  
     }
 1148  
 
 1149  
     public void setTrimStackTrace( boolean trimStackTrace )
 1150  
     {
 1151  0
         this.trimStackTrace = trimStackTrace;
 1152  0
     }
 1153  
 
 1154  
     public ArtifactResolver getArtifactResolver()
 1155  
     {
 1156  0
         return artifactResolver;
 1157  
     }
 1158  
 
 1159  
     public void setArtifactResolver( ArtifactResolver artifactResolver )
 1160  
     {
 1161  0
         this.artifactResolver = artifactResolver;
 1162  0
     }
 1163  
 
 1164  
     public ArtifactFactory getArtifactFactory()
 1165  
     {
 1166  0
         return artifactFactory;
 1167  
     }
 1168  
 
 1169  
     public void setArtifactFactory( ArtifactFactory artifactFactory )
 1170  
     {
 1171  0
         this.artifactFactory = artifactFactory;
 1172  0
     }
 1173  
 
 1174  
     public List getRemoteRepositories()
 1175  
     {
 1176  0
         return remoteRepositories;
 1177  
     }
 1178  
 
 1179  
     public void setRemoteRepositories( List remoteRepositories )
 1180  
     {
 1181  0
         this.remoteRepositories = remoteRepositories;
 1182  0
     }
 1183  
 
 1184  
     public ArtifactMetadataSource getMetadataSource()
 1185  
     {
 1186  0
         return metadataSource;
 1187  
     }
 1188  
 
 1189  
     public void setMetadataSource( ArtifactMetadataSource metadataSource )
 1190  
     {
 1191  0
         this.metadataSource = metadataSource;
 1192  0
     }
 1193  
 
 1194  
     public Properties getOriginalSystemProperties()
 1195  
     {
 1196  0
         return originalSystemProperties;
 1197  
     }
 1198  
 
 1199  
     public void setOriginalSystemProperties( Properties originalSystemProperties )
 1200  
     {
 1201  0
         this.originalSystemProperties = originalSystemProperties;
 1202  0
     }
 1203  
 
 1204  
     public Properties getInternalSystemProperties()
 1205  
     {
 1206  0
         return internalSystemProperties;
 1207  
     }
 1208  
 
 1209  
     public void setInternalSystemProperties( Properties internalSystemProperties )
 1210  
     {
 1211  0
         this.internalSystemProperties = internalSystemProperties;
 1212  0
     }
 1213  
 
 1214  
     public boolean isDisableXmlReport()
 1215  
     {
 1216  0
         return disableXmlReport;
 1217  
     }
 1218  
 
 1219  
     public void setDisableXmlReport( boolean disableXmlReport )
 1220  
     {
 1221  0
         this.disableXmlReport = disableXmlReport;
 1222  0
     }
 1223  
 
 1224  
     public boolean isUseSystemClassLoader()
 1225  
     {
 1226  0
         return useSystemClassLoader;
 1227  
     }
 1228  
 
 1229  
     public void setUseSystemClassLoader( boolean useSystemClassLoader )
 1230  
     {
 1231  0
         this.useSystemClassLoader = useSystemClassLoader;
 1232  0
     }
 1233  
 
 1234  
     public boolean isUseManifestOnlyJar()
 1235  
     {
 1236  0
         return useManifestOnlyJar;
 1237  
     }
 1238  
 
 1239  
     public void setUseManifestOnlyJar( boolean useManifestOnlyJar )
 1240  
     {
 1241  0
         this.useManifestOnlyJar = useManifestOnlyJar;
 1242  0
     }
 1243  
 
 1244  
     public boolean isEnableAssertions()
 1245  
     {
 1246  0
         return enableAssertions;
 1247  
     }
 1248  
 
 1249  
     public void setEnableAssertions( boolean enableAssertions )
 1250  
     {
 1251  0
         this.enableAssertions = enableAssertions;
 1252  0
     }
 1253  
 
 1254  
     public MavenSession getSession()
 1255  
     {
 1256  0
         return session;
 1257  
     }
 1258  
 
 1259  
     public void setSession( MavenSession session )
 1260  
     {
 1261  0
         this.session = session;
 1262  0
     }
 1263  
 
 1264  
     public String getObjectFactory()
 1265  
     {
 1266  0
         return objectFactory;
 1267  
     }
 1268  
 
 1269  
     public void setObjectFactory( String objectFactory )
 1270  
     {
 1271  0
         this.objectFactory = objectFactory;
 1272  0
     }
 1273  
 
 1274  
     public ToolchainManager getToolchainManager()
 1275  
     {
 1276  0
         return toolchainManager;
 1277  
     }
 1278  
 
 1279  
     public void setToolchainManager( ToolchainManager toolchainManager )
 1280  
     {
 1281  0
         this.toolchainManager = toolchainManager;
 1282  0
     }
 1283  
 
 1284  
     public boolean isMavenParallel()
 1285  
     {
 1286  0
         return parallelMavenExecution != null && parallelMavenExecution.booleanValue();
 1287  
     }
 1288  
 
 1289  
     public String getRunOrder()
 1290  
     {
 1291  0
         return runOrder;
 1292  
     }
 1293  
 
 1294  
     public void setRunOrder( String runOrder )
 1295  
     {
 1296  0
         this.runOrder = runOrder;
 1297  0
     }
 1298  
 
 1299  
     protected void addPluginSpecificChecksumItems( ChecksumCalculator checksum )
 1300  
     {
 1301  0
     }
 1302  
     
 1303  
 }