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