Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.apache.maven.plugin.surefire;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.surefire.suite.RunResult;
import static org.apache.maven.plugin.surefire.SurefireHelper.reportExecution;
/**
* Run tests using Surefire.
*
* @author Jason van Zyl
*/
@Mojo( name = "test", defaultPhase = LifecyclePhase.TEST, threadSafe = true,
requiresDependencyResolution = ResolutionScope.TEST )
public class SurefirePlugin
extends AbstractSurefireMojo
implements SurefireReportParameters
{
/**
* The directory containing generated classes of the project being tested. This will be included after the test
* classes in the test classpath.
*/
@Parameter( defaultValue = "${project.build.outputDirectory}" )
private File classesDirectory;
/**
* Set this to "true" to ignore a failure during testing. Its use is NOT RECOMMENDED, but quite convenient on
* occasion.
*/
@Parameter( property = "maven.test.failure.ignore", defaultValue = "false" )
private boolean testFailureIgnore;
/**
* Base directory where all reports are written to.
*/
@Parameter( defaultValue = "${project.build.directory}/surefire-reports" )
private File reportsDirectory;
@SuppressWarnings( "checkstyle:linelength" )
/**
* Specify this parameter to run individual tests by file name, overriding the parameter {@code includes} and
* {@code excludes}. Each pattern you specify here will be used to create an include pattern formatted like
* **{@literal /}${test}.java, so you can just type {@code -Dtest=MyTest} to run a single test called
* "foo/MyTest.java". The test patterns prefixed with a ! will be excluded.
*
* This parameter overrides the parameter {@code includes}, {@code excludes}, and the TestNG parameter
* {@code suiteXmlFiles}.
*
* Since 2.7.3, you can execute a limited number of methods in the test by adding #myMethod or
* #my*ethod. For example, {@code -Dtest=MyTest#myMethod}. This is supported for junit 4.x and TestNg.
*
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
*
*
* The Parameterized JUnit runner {@code describes} test methods using an index in brackets, so the non-regex
* method pattern would become: {@code #testMethod[*]}.
* If using @Parameters(name="{index}: fib({0})={1}") and selecting the index e.g. 5 in pattern, the
* non-regex method pattern would become {@code #testMethod[5:*]}.
*/
@Parameter( property = "test" )
private String test;
/**
* Option to print summary of test suites or just print the test cases that have errors.
*/
@Parameter( property = "surefire.printSummary", defaultValue = "true" )
private boolean printSummary;
/**
* Selects the formatting for the test report to be generated. Can be set as "brief" or "plain".
* Only applies to the output format of the output files (target/surefire-reports/testName.txt)
*/
@Parameter( property = "surefire.reportFormat", defaultValue = "brief" )
private String reportFormat;
/**
* Option to generate a file test report or just output the test report to the console.
*/
@Parameter( property = "surefire.useFile", defaultValue = "true" )
private boolean useFile;
/**
* Set this to "true" to cause a failure if none of the tests specified in -Dtest=... are run. Defaults to
* "true".
*
* @since 2.12
*/
@Parameter( property = "surefire.failIfNoSpecifiedTests" )
private Boolean failIfNoSpecifiedTests;
/**
* Attach a debugger to the forked JVM. If set to "true", the process will suspend and wait for a debugger to attach
* on port 5005. If set to some other string, that string will be appended to the argLine, allowing you to configure
* arbitrary debuggability options (without overwriting the other options specified through the {@code argLine}
* parameter).
*
* @since 2.4
*/
@Parameter( property = "maven.surefire.debug" )
private String debugForkedProcess;
/**
* Kill the forked test process after a certain number of seconds. If set to 0, wait forever for the process, never
* timing out.
*
* @since 2.4
*/
@Parameter( property = "surefire.timeout" )
private int forkedProcessTimeoutInSeconds;
/**
* Forked process is normally terminated without any significant delay after given tests have completed.
* If the particular tests started non-daemon Thread(s), the process hangs instead of been properly terminated
* by {@code System.exit()}. Use this parameter in order to determine the timeout of terminating the process.
* see the documentation:
* http://maven.apache.org/surefire/maven-surefire-plugin/examples/shutdown.html
* Turns to default fallback value of 30 seconds if negative integer.
*
* @since 2.20
*/
@Parameter( property = "surefire.exitTimeout", defaultValue = "30" )
private int forkedProcessExitTimeoutInSeconds;
/**
* Stop executing queued parallel JUnit tests after a certain number of seconds.
*
* Example values: "3.5", "4"
*
* If set to 0, wait forever, never timing out.
* Makes sense with specified {@code parallel} different from "none".
*
* @since 2.16
*/
@Parameter( property = "surefire.parallel.timeout" )
private double parallelTestsTimeoutInSeconds;
/**
* Stop executing queued parallel JUnit tests
* and {@code interrupt} currently running tests after a certain number of seconds.
*
* Example values: "3.5", "4"
*
* If set to 0, wait forever, never timing out.
* Makes sense with specified {@code parallel} different from "none".
*
* @since 2.16
*/
@Parameter( property = "surefire.parallel.forcedTimeout" )
private double parallelTestsTimeoutForcedInSeconds;
@SuppressWarnings( "checkstyle:linelength" )
/**
* A list of <include> elements specifying the tests (by pattern) that should be included in testing. When not
* specified and when the {@code test} parameter is not specified, the default includes will be
*
* Each include item may also contain a comma-separated sub-list of items, which will be treated as multiple
* <include> entries.
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
*
*
*
* {@literal }%regex[.*[Cat|Dog].*], Basic????, !Unstable*{@literal }
* {@literal }%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg{@literal /}**{@literal /}*Fast*.java{@literal }
*
* This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified.
*
* Notice that these values are relative to the directory containing generated test classes of the project
* being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults
* to the POM property {@code ${project.build.testOutputDirectory}}, typically
* {@literal src/test/java} unless overridden.
*/
@Parameter
private List includes;
/**
* Option to pass dependencies to the system's classloader instead of using an isolated class loader when forking.
* Prevents problems with JDKs which implement the service provider lookup mechanism by using the system's
* ClassLoader.
*
* @since 2.3
*/
@Parameter( property = "surefire.useSystemClassLoader", defaultValue = "true" )
private boolean useSystemClassLoader;
/**
* By default, Surefire forks your tests using a manifest-only JAR; set this parameter to "false" to force it to
* launch your tests with a plain old Java classpath. (See the
*
* http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html
* for a more detailed explanation of manifest-only JARs and their benefits.)
*
* Beware, setting this to "false" may cause your tests to fail on Windows if your classpath is too long.
*
* @since 2.4.3
*/
@Parameter( property = "surefire.useManifestOnlyJar", defaultValue = "true" )
private boolean useManifestOnlyJar;
/**
* The character encoding scheme to be applied while generating test report
* files (see target/surefire-reports/yourTestName.txt).
* The report output files (*-out.txt) are still encoded with JVM's encoding used in standard out/err pipes.
*
* @since 3.0.0-M1
*/
@Parameter( property = "surefire.encoding", defaultValue = "${project.reporting.outputEncoding}" )
private String encoding;
/**
* (JUnit 4+ providers)
* The number of times each failing test will be rerun. If set larger than 0, rerun failing tests immediately after
* they fail. If a failing test passes in any of those reruns, it will be marked as pass and reported as a "flake".
* However, all the failing attempts will be recorded.
*/
@Parameter( property = "surefire.rerunFailingTestsCount", defaultValue = "0" )
private int rerunFailingTestsCount;
/**
* (TestNG) List of <suiteXmlFile> elements specifying TestNG suite xml file locations. Note that
* {@code suiteXmlFiles} is incompatible with several other parameters of this plugin, like
* {@code includes} and {@code excludes}.
* This parameter is ignored if the {@code test} parameter is specified (allowing you to run a single test
* instead of an entire suite).
*
* @since 2.2
*/
@Parameter( property = "surefire.suiteXmlFiles" )
private File[] suiteXmlFiles;
/**
* Defines the order the tests will be run in. Supported values are {@code alphabetical},
* {@code reversealphabetical}, {@code random}, {@code hourly} (alphabetical on even hours, reverse alphabetical
* on odd hours), {@code failedfirst}, {@code balanced} and {@code filesystem}.
*
*
* Odd/Even for hourly is determined at the time the of scanning the classpath, meaning it could change during a
* multi-module build.
*
*
* Failed first will run tests that failed on previous run first, as well as new tests for this run.
*
*
* Balanced is only relevant with parallel=classes, and will try to optimize the run-order of the tests reducing the
* overall execution time. Initially a statistics file is created and every next test run will reorder classes.
*
*
* Note that the statistics are stored in a file named .surefire-XXXXXXXXX beside pom.xml and
* should not be checked into version control. The "XXXXX" is the SHA1 checksum of the entire surefire
* configuration, so different configurations will have different statistics files, meaning if you change any
* configuration settings you will re-run once before new statistics data can be established.
*
* @since 2.7
*/
@Parameter( property = "surefire.runOrder", defaultValue = "filesystem" )
private String runOrder;
/**
* A file containing include patterns. Blank lines, or lines starting with # are ignored. If {@code includes} are
* also specified, these patterns are appended. Example with path, simple and regex includes:
*
*/
@Parameter( property = "surefire.includesFile" )
private File includesFile;
/**
* A file containing exclude patterns. Blank lines, or lines starting with # are ignored. If {@code excludes} are
* also specified, these patterns are appended. Example with path, simple and regex excludes:
*