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