You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2015/06/05 23:35:53 UTC
[2/2] maven-surefire git commit: [SUREFIRE-1158] Remove console
println of TestNG configurator
[SUREFIRE-1158] Remove console println of TestNG configurator
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/67e6606d
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/67e6606d
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/67e6606d
Branch: refs/heads/master
Commit: 67e6606d51e24ecfd4bfe75e4f4dd906f9e88435
Parents: 4506914
Author: Tibor17 <ti...@lycos.com>
Authored: Thu Jun 4 08:12:47 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Thu Jun 4 08:12:47 2015 +0200
----------------------------------------------------------------------
.../maven/plugin/failsafe/VerifyMojo.java | 29 +++-
.../plugin/surefire/AbstractSurefireMojo.java | 144 +++++++++++++-----
.../maven/plugin/surefire/ProviderList.java | 109 --------------
.../maven/plugin/surefire/SurefireHelper.java | 92 +++++++++++-
.../plugin/surefire/SurefireProperties.java | 3 +-
.../surefire/booterclient/BooterSerializer.java | 76 +++++-----
...erDeserializerProviderConfigurationTest.java | 22 ++-
...terDeserializerStartupConfigurationTest.java | 11 +-
.../src/site/apt/examples/logging.apt.vm | 56 +++++++
maven-surefire-plugin/src/site/site.xml | 1 +
pom.xml | 2 +-
.../surefire/booter/BaseProviderFactory.java | 22 ++-
.../maven/surefire/cli/CommandLineOption.java | 58 ++++++++
.../providerapi/ProviderParameters.java | 3 +
.../maven/surefire/booter/BooterConstants.java | 1 +
.../surefire/booter/BooterDeserializer.java | 6 +-
.../maven/surefire/booter/ForkedBooter.java | 1 +
.../surefire/booter/ProviderConfiguration.java | 14 +-
.../maven/surefire/its/JUnit47ParallelIT.java | 3 +-
.../maven/surefire/its/TestMethodPatternIT.java | 8 +-
.../surefire/its/TestMultipleMethodsIT.java | 8 +-
.../maven/surefire/its/TestSingleMethodIT.java | 9 +-
.../surefire/its/fixture/MavenLauncher.java | 17 ++-
.../SurefireJUnit4IntegrationTestCase.java | 9 +-
.../Surefire1152RerunFailingTestsInSuiteIT.java | 7 +-
.../jiras/Surefire1158RemoveInfoLinesIT.java | 145 +++++++++++++++++++
.../jiras/Surefire141PluggableProvidersIT.java | 43 ++++--
.../Surefire408ManualProviderSelectionIT.java | 9 +-
.../surefire-1158-remove-info-lines/pom.xml | 77 ++++++++++
.../src/test/java/jira1158/JUnitTest.java | 31 ++++
.../src/test/java/jira1158/TestNGSuiteTest.java | 32 ++++
.../testng/TestNGDirectoryTestSuite.java | 20 ++-
.../maven/surefire/testng/TestNGExecutor.java | 15 +-
.../maven/surefire/testng/TestNGProvider.java | 8 +-
34 files changed, 845 insertions(+), 246 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
----------------------------------------------------------------------
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
index b3b60c6..ab176d6 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
@@ -25,17 +25,22 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.util.Collection;
+
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.surefire.SurefireHelper;
import org.apache.maven.plugin.surefire.SurefireReportParameters;
+import org.apache.maven.plugins.annotations.Component;
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.shared.utils.ReaderFactory;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.shared.utils.io.IOUtil;
+import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.suite.RunResult;
/**
@@ -145,13 +150,21 @@ public class VerifyMojo
@Parameter( property = "encoding", defaultValue = "${project.reporting.outputEncoding}" )
private String encoding;
+ /**
+ * The current build session instance.
+ */
+ @Component
+ protected MavenSession session;
+
+ private Collection<CommandLineOption> cli;
public void execute()
throws MojoExecutionException, MojoFailureException
{
+ cli = commandLineOptions();
if ( verifyParameters() )
{
- getLog().info(
+ logDebugOrCliShowErrors(
StringUtils.capitalizeFirstLetter( getPluginName() ) + " report directory: " + getReportsDirectory() );
RunResult summary;
@@ -160,8 +173,8 @@ public class VerifyMojo
final String encoding;
if ( StringUtils.isEmpty( this.encoding ) )
{
- getLog().warn(
- "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
+ getLog().warn( "File encoding has not been set, using platform encoding "
+ + ReaderFactory.FILE_ENCODING
+ ", i.e. build is platform dependent! The file encoding for reports output files "
+ "should be provided by the POM property ${project.reporting.outputEncoding}." );
encoding = ReaderFactory.FILE_ENCODING;
@@ -354,4 +367,14 @@ public class VerifyMojo
return existsSummaryFile() || existsSummaryFiles();
}
+ private Collection<CommandLineOption> commandLineOptions()
+ {
+ return SurefireHelper.commandLineOptions( session, getLog() );
+ }
+
+ private void logDebugOrCliShowErrors( CharSequence s )
+ {
+ SurefireHelper.logDebugOrCliShowErrors( s, getLog(), cli );
+ }
+
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 014f1a8..81c8a1b 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -61,6 +61,7 @@ import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.surefire.booterclient.ChecksumCalculator;
import org.apache.maven.plugin.surefire.booterclient.ForkConfiguration;
import org.apache.maven.plugin.surefire.booterclient.ForkStarter;
+import org.apache.maven.plugin.surefire.booterclient.ProviderDetector;
import org.apache.maven.plugin.surefire.util.DependencyScanner;
import org.apache.maven.plugin.surefire.util.DirectoryScanner;
import org.apache.maven.plugins.annotations.Component;
@@ -78,6 +79,8 @@ import org.apache.maven.surefire.booter.ProviderParameterNames;
import org.apache.maven.surefire.booter.StartupConfiguration;
import org.apache.maven.surefire.booter.SurefireBooterForkException;
import org.apache.maven.surefire.booter.SurefireExecutionException;
+import org.apache.maven.surefire.cli.CommandLineOption;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.suite.RunResult;
import org.apache.maven.surefire.testset.DirectoryScannerParameters;
@@ -686,9 +689,12 @@ public abstract class AbstractSurefireMojo
private TestListResolver includedExcludedTests;
+ private List<CommandLineOption> cli;
+
public void execute()
throws MojoExecutionException, MojoFailureException
{
+ cli = commandLineOptions();
// Stuff that should have been final
setupStuff();
@@ -849,7 +855,6 @@ public abstract class AbstractSurefireMojo
handleSummary( current, firstForkException );
}
-
private void createDependencyResolver()
{
dependencyResolver =
@@ -860,15 +865,13 @@ public abstract class AbstractSurefireMojo
protected List<ProviderInfo> createProviders()
throws MojoFailureException, MojoExecutionException
{
- final Artifact junitDepArtifact = getJunitDepArtifact();
- ProviderList wellKnownProviders =
- new ProviderList( new DynamicProviderInfo( null ),
+ Artifact junitDepArtifact = getJunitDepArtifact();
+ return new ProviderList( new DynamicProviderInfo( null ),
new TestNgProviderInfo( getTestNgArtifact() ),
new JUnitCoreProviderInfo( getJunitArtifact(), junitDepArtifact ),
new JUnit4ProviderInfo( getJunitArtifact(), junitDepArtifact ),
- new JUnit3ProviderInfo() );
-
- return wellKnownProviders.resolve( getLog() );
+ new JUnit3ProviderInfo() )
+ .resolve();
}
private SurefireProperties setupProperties()
@@ -993,7 +996,6 @@ public abstract class AbstractSurefireMojo
}
}
-
public static SurefireProperties createCopyAndReplaceForkNumPlaceholder(
SurefireProperties effectiveSystemProperties, int threadNumber )
{
@@ -1034,11 +1036,10 @@ public abstract class AbstractSurefireMojo
protected void logReportsDirectory()
{
- getLog().info(
+ logDebugOrCliShowErrors(
StringUtils.capitalizeFirstLetter( getPluginName() ) + " report directory: " + getReportsDirectory() );
}
-
final Toolchain getToolchain()
{
Toolchain tc = null;
@@ -1159,9 +1160,8 @@ public abstract class AbstractSurefireMojo
checkNonForkedThreads( parallel );
}
- String usedThreadCount = Integer.toString( getThreadCount() );
getProperties().setProperty( ProviderParameterNames.PARALLEL_PROP, usedParallel );
- getProperties().setProperty( ProviderParameterNames.THREADCOUNT_PROP, usedThreadCount );
+ getProperties().setProperty( ProviderParameterNames.THREADCOUNT_PROP, Integer.toString( getThreadCount() ) );
getProperties().setProperty( "perCoreThreadCount", Boolean.toString( getPerCoreThreadCount() ) );
getProperties().setProperty( "useUnlimitedThreads", Boolean.toString( getUseUnlimitedThreads() ) );
getProperties().setProperty( ProviderParameterNames.THREADCOUNTSUITES_PROP,
@@ -1171,21 +1171,22 @@ public abstract class AbstractSurefireMojo
getProperties().setProperty( ProviderParameterNames.THREADCOUNTMETHODS_PROP,
Integer.toString( getThreadCountMethods() ) );
getProperties().setProperty( ProviderParameterNames.PARALLEL_TIMEOUT_PROP,
- Double.toString( getParallelTestsTimeoutInSeconds() ) );
+ Double.toString( getParallelTestsTimeoutInSeconds() ) );
getProperties().setProperty( ProviderParameterNames.PARALLEL_TIMEOUTFORCED_PROP,
- Double.toString( getParallelTestsTimeoutForcedInSeconds() ) );
+ Double.toString( getParallelTestsTimeoutForcedInSeconds() ) );
getProperties().setProperty( ProviderParameterNames.PARALLEL_OPTIMIZE_PROP,
Boolean.toString( isParallelOptimized() ) );
- String message =
- "parallel='" + usedParallel + '\'' + ", perCoreThreadCount=" + getPerCoreThreadCount() + ", threadCount="
- + usedThreadCount + ", useUnlimitedThreads=" + getUseUnlimitedThreads()
- + ", threadCountSuites=" + getThreadCountSuites()
- + ", threadCountClasses=" + getThreadCountClasses()
- + ", threadCountMethods=" + getThreadCountMethods()
- + ", parallelOptimized=" + isParallelOptimized();
+ String message = "parallel='" + usedParallel + '\''
+ + ", perCoreThreadCount=" + getPerCoreThreadCount()
+ + ", threadCount=" + getThreadCount()
+ + ", useUnlimitedThreads=" + getUseUnlimitedThreads()
+ + ", threadCountSuites=" + getThreadCountSuites()
+ + ", threadCountClasses=" + getThreadCountClasses()
+ + ", threadCountMethods=" + getThreadCountMethods()
+ + ", parallelOptimized=" + isParallelOptimized();
- getLog().info( message );
+ logDebugOrCliShowErrors( message );
}
private void checkNonForkedThreads( String parallel ) throws MojoExecutionException
@@ -1447,7 +1448,7 @@ public abstract class AbstractSurefireMojo
reporterConfiguration,
testNg, // Not really used in provider. Limited to de/serializer.
testSuiteDefinition, providerProperties, null,
- false );
+ false, cli );
}
private static Map<String, String> toStringProperties( Properties properties )
@@ -2301,6 +2302,11 @@ public abstract class AbstractSurefireMojo
return !isForking();
}
+ private List<CommandLineOption> commandLineOptions()
+ {
+ return SurefireHelper.commandLineOptions( getSession(), getLog() );
+ }
+
void warnIfDefunctGroupsCombinations()
throws MojoFailureException, MojoExecutionException
{
@@ -2327,7 +2333,7 @@ public abstract class AbstractSurefireMojo
}
}
- class TestNgProviderInfo
+ final class TestNgProviderInfo
implements ProviderInfo
{
private final Artifact testNgArtifact;
@@ -2362,7 +2368,7 @@ public abstract class AbstractSurefireMojo
}
}
- class JUnit3ProviderInfo
+ final class JUnit3ProviderInfo
implements ProviderInfo
{
@Nonnull public String getProviderName()
@@ -2388,10 +2394,9 @@ public abstract class AbstractSurefireMojo
null );
}
-
}
- class JUnit4ProviderInfo
+ final class JUnit4ProviderInfo
implements ProviderInfo
{
private final Artifact junitArtifact;
@@ -2423,12 +2428,11 @@ public abstract class AbstractSurefireMojo
{
return dependencyResolver.getProviderClasspath( "surefire-junit4", surefireBooterArtifact.getBaseVersion(),
null );
-
}
}
- class JUnitCoreProviderInfo
+ final class JUnitCoreProviderInfo
implements ProviderInfo
{
private final Artifact junitArtifact;
@@ -2470,14 +2474,12 @@ public abstract class AbstractSurefireMojo
return dependencyResolver.getProviderClasspath( "surefire-junit47", surefireBooterArtifact.getBaseVersion(),
null );
}
-
}
/**
- * Provides the Provider information for manually configured providers
- *
+ * Provides the Provider information for manually configured providers.
*/
- public class DynamicProviderInfo
+ final class DynamicProviderInfo
implements ConfigurableProviderInfo
{
final String providerName;
@@ -2510,7 +2512,6 @@ public abstract class AbstractSurefireMojo
convertTestNGParameters();
}
-
public Classpath getProviderClasspath()
throws ArtifactResolutionException, ArtifactNotFoundException
{
@@ -2518,7 +2519,77 @@ public abstract class AbstractSurefireMojo
Artifact plugin = pluginArtifactMap.get( "org.apache.maven.plugins:maven-surefire-plugin" );
return dependencyResolver.addProviderToClasspath( pluginArtifactMap, plugin );
}
+ }
+
+ /**
+ * @author Kristian Rosenvold
+ */
+ final class ProviderList
+ {
+ private final ProviderInfo[] wellKnownProviders;
+
+ private final ConfigurableProviderInfo dynamicProvider;
+
+ ProviderList( ConfigurableProviderInfo dynamicProviderInfo, ProviderInfo... wellKnownProviders )
+ {
+ this.wellKnownProviders = wellKnownProviders;
+ this.dynamicProvider = dynamicProviderInfo;
+ }
+
+ @SuppressWarnings( "checkstyle:modifierorder" )
+ @Nonnull List<ProviderInfo> resolve()
+ {
+ List<ProviderInfo> providersToRun = new ArrayList<ProviderInfo>();
+ Set<String> manuallyConfiguredProviders = getManuallyConfiguredProviders();
+ for ( String name : manuallyConfiguredProviders )
+ {
+ ProviderInfo wellKnown = findByName( name );
+ ProviderInfo providerToAdd = wellKnown != null ? wellKnown : dynamicProvider.instantiate( name );
+ logDebugOrCliShowErrors( "Using configured provider " + providerToAdd.getProviderName() );
+ providersToRun.add( providerToAdd );
+ }
+ return manuallyConfiguredProviders.isEmpty() ? autoDetectOneProvider() : providersToRun;
+ }
+ @SuppressWarnings( "checkstyle:modifierorder" )
+ private @Nonnull List<ProviderInfo> autoDetectOneProvider()
+ {
+ List<ProviderInfo> providersToRun = new ArrayList<ProviderInfo>();
+ for ( ProviderInfo wellKnownProvider : wellKnownProviders )
+ {
+ if ( wellKnownProvider.isApplicable() )
+ {
+ providersToRun.add( wellKnownProvider );
+ return providersToRun;
+ }
+ }
+ return providersToRun;
+ }
+
+ private Set<String> getManuallyConfiguredProviders()
+ {
+ try
+ {
+ return ProviderDetector.getServiceNames( SurefireProvider.class,
+ Thread.currentThread().getContextClassLoader() );
+ }
+ catch ( IOException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+
+ private ProviderInfo findByName( String providerClassName )
+ {
+ for ( ProviderInfo wellKnownProvider : wellKnownProviders )
+ {
+ if ( wellKnownProvider.getProviderName().equals( providerClassName ) )
+ {
+ return wellKnownProvider;
+ }
+ }
+ return null;
+ }
}
public abstract List<String> getIncludes();
@@ -3055,4 +3126,9 @@ public abstract class AbstractSurefireMojo
{
this.classpathDependencyScopeExclude = classpathDependencyScopeExclude;
}
+
+ protected void logDebugOrCliShowErrors( CharSequence s )
+ {
+ SurefireHelper.logDebugOrCliShowErrors( s, getLog(), cli );
+ }
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java
deleted file mode 100644
index fe02d56..0000000
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ProviderList.java
+++ /dev/null
@@ -1,109 +0,0 @@
-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.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.plugin.surefire.booterclient.ProviderDetector;
-import org.apache.maven.surefire.providerapi.SurefireProvider;
-
-import javax.annotation.Nonnull;
-
-/**
- * @author Kristian Rosenvold
- */
-public class ProviderList
-{
- private final ProviderInfo[] wellKnownProviders;
-
- private final ConfigurableProviderInfo dynamicProvider;
-
- public ProviderList( ConfigurableProviderInfo dynamicProviderInfo, ProviderInfo... wellKnownProviders )
- {
- this.wellKnownProviders = wellKnownProviders;
- this.dynamicProvider = dynamicProviderInfo;
- }
-
-
- @SuppressWarnings( "checkstyle:modifierorder" )
- public @Nonnull List<ProviderInfo> resolve( @Nonnull Log log )
- {
- List<ProviderInfo> providersToRun = new ArrayList<ProviderInfo>();
-
- Set<String> manuallyConfiguredProviders = getManuallyConfiguredProviders();
- if ( !manuallyConfiguredProviders.isEmpty() )
- {
- for ( String name : manuallyConfiguredProviders )
- {
- ProviderInfo wellKnown = findByName( name );
- ProviderInfo providerToAdd = wellKnown != null ? wellKnown : dynamicProvider.instantiate( name );
- log.info( "Using configured provider " + providerToAdd.getProviderName() );
- providersToRun.add( providerToAdd );
- }
- return providersToRun;
- }
-
- return autoDetectOneProvider();
- }
-
- @SuppressWarnings( "checkstyle:modifierorder" )
- private @Nonnull List<ProviderInfo> autoDetectOneProvider()
- {
- List<ProviderInfo> providersToRun = new ArrayList<ProviderInfo>();
- for ( ProviderInfo wellKnownProvider : wellKnownProviders )
- {
- if ( wellKnownProvider.isApplicable() )
- {
- providersToRun.add( wellKnownProvider );
- return providersToRun;
- }
- }
- return providersToRun;
- }
-
- private Set<String> getManuallyConfiguredProviders()
- {
- try
- {
- return ProviderDetector.getServiceNames( SurefireProvider.class,
- Thread.currentThread().getContextClassLoader() );
- }
-
- catch ( IOException e )
- {
- throw new RuntimeException( e );
- }
- }
-
- private ProviderInfo findByName( String providerClassName )
- {
- for ( ProviderInfo wellKnownProvider : wellKnownProviders )
- {
- if ( wellKnownProvider.getProviderName().equals( providerClassName ) )
- {
- return wellKnownProvider;
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
index 2af5fa8..a4319bc 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
@@ -19,11 +19,21 @@ package org.apache.maven.plugin.surefire;
* under the License.
*/
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.suite.RunResult;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
/**
* Helper class for surefire plugins
*/
@@ -41,7 +51,6 @@ public final class SurefireHelper
public static void reportExecution( SurefireReportParameters reportParameters, RunResult result, Log log )
throws MojoFailureException, MojoExecutionException
{
-
boolean timeoutOrOtherFailure = result.isFailureOrTimeout();
if ( !timeoutOrOtherFailure )
@@ -84,4 +93,85 @@ public final class SurefireHelper
}
}
+ public static List<CommandLineOption> commandLineOptions( MavenSession session, Log log )
+ {
+ List<CommandLineOption> cli = new ArrayList<CommandLineOption>();
+ if ( log.isErrorEnabled() )
+ {
+ cli.add( CommandLineOption.LOGGING_LEVEL_ERROR );
+ }
+
+ if ( log.isWarnEnabled() )
+ {
+ cli.add( CommandLineOption.LOGGING_LEVEL_WARN );
+ }
+
+ if ( log.isInfoEnabled() )
+ {
+ cli.add( CommandLineOption.LOGGING_LEVEL_INFO );
+ }
+
+ if ( log.isDebugEnabled() )
+ {
+ cli.add( CommandLineOption.LOGGING_LEVEL_DEBUG );
+ }
+
+ try
+ {
+ Method getRequestMethod = session.getClass().getMethod( "getRequest" );
+ MavenExecutionRequest request = (MavenExecutionRequest) getRequestMethod.invoke( session );
+
+ String f = getFailureBehavior( request );
+ if ( f != null )
+ {
+ // compatible with enums Maven 3.0
+ cli.add( CommandLineOption.valueOf( f.startsWith( "REACTOR_" ) ? f : "REACTOR_" + f ) );
+ }
+
+ if ( request.isShowErrors() )
+ {
+ cli.add( CommandLineOption.SHOW_ERRORS );
+ }
+ }
+ catch ( Exception e )
+ {
+ // don't need to log the exception that Maven 2 does not have getRequest() method in Maven Session
+ }
+ return Collections.unmodifiableList( cli );
+ }
+
+ public static void logDebugOrCliShowErrors( CharSequence s, Log log, Collection<CommandLineOption> cli )
+ {
+ if ( cli.contains( CommandLineOption.LOGGING_LEVEL_DEBUG ) )
+ {
+ log.debug( s );
+ }
+ else if ( cli.contains( CommandLineOption.SHOW_ERRORS ) )
+ {
+ if ( log.isDebugEnabled() )
+ {
+ log.debug( s );
+ }
+ else
+ {
+ log.info( s );
+ }
+ }
+ }
+
+ private static String getFailureBehavior( MavenExecutionRequest request )
+ throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
+ {
+ try
+ {
+ return request.getFailureBehavior();
+ }
+ catch ( NoSuchMethodError e )
+ {
+ return (String) request.getClass()
+ .getMethod( "getReactorFailureBehavior" )
+ .invoke( request );
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
index 0cb9e73..472c51a 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireProperties.java
@@ -195,7 +195,7 @@ public class SurefireProperties
}
}
- public void addList( List items, String propertyPrefix )
+ public void addList( List<?> items, String propertyPrefix )
{
if ( items == null || items.isEmpty() )
{
@@ -216,7 +216,6 @@ public class SurefireProperties
setProperty( propertyPrefix + i, aStringArray );
i++;
}
-
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
index be9a284..4b2aeaf 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
@@ -21,15 +21,16 @@ package org.apache.maven.plugin.surefire.booterclient;
import java.io.File;
import java.io.IOException;
+import java.util.List;
import org.apache.maven.plugin.surefire.SurefireProperties;
-import org.apache.maven.surefire.booter.BooterConstants;
import org.apache.maven.surefire.booter.ClassLoaderConfiguration;
import org.apache.maven.surefire.booter.ClasspathConfiguration;
import org.apache.maven.surefire.booter.KeyValueSource;
import org.apache.maven.surefire.booter.ProviderConfiguration;
import org.apache.maven.surefire.booter.StartupConfiguration;
import org.apache.maven.surefire.booter.SystemPropertyManager;
+import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.testset.DirectoryScannerParameters;
import org.apache.maven.surefire.testset.RunOrderParameters;
@@ -38,6 +39,10 @@ import org.apache.maven.surefire.testset.TestListResolver;
import org.apache.maven.surefire.testset.TestRequest;
import org.apache.maven.surefire.util.RunOrder;
+// CHECKSTYLE_OFF: imports
+import static org.apache.maven.surefire.booter.BooterConstants.*;
+import static org.apache.maven.surefire.cli.CommandLineOption.*;
+
/**
* Knows how to serialize and deserialize the booter configuration.
* <p/>
@@ -62,9 +67,8 @@ class BooterSerializer
this.forkConfiguration = forkConfiguration;
}
-
- /*
- DOes not modify sourceProperties
+ /**
+ * Does not modify sourceProperties
*/
public File serialize( KeyValueSource sourceProperties, ProviderConfiguration booterConfiguration,
StartupConfiguration providerConfiguration, Object testSet, boolean readTestsFromInStream )
@@ -82,64 +86,62 @@ class BooterSerializer
TestArtifactInfo testNg = booterConfiguration.getTestArtifact();
if ( testNg != null )
{
- properties.setProperty( BooterConstants.TESTARTIFACT_VERSION, testNg.getVersion() );
- properties.setNullableProperty( BooterConstants.TESTARTIFACT_CLASSIFIER, testNg.getClassifier() );
+ properties.setProperty( TESTARTIFACT_VERSION, testNg.getVersion() );
+ properties.setNullableProperty( TESTARTIFACT_CLASSIFIER, testNg.getClassifier() );
}
- properties.setProperty( BooterConstants.FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM, readTestsFromInStream );
- properties.setNullableProperty( BooterConstants.FORKTESTSET, getTypeEncoded( testSet ) );
+ properties.setProperty( FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM, readTestsFromInStream );
+ properties.setNullableProperty( FORKTESTSET, getTypeEncoded( testSet ) );
TestRequest testSuiteDefinition = booterConfiguration.getTestSuiteDefinition();
if ( testSuiteDefinition != null )
{
- properties.setProperty( BooterConstants.SOURCE_DIRECTORY, testSuiteDefinition.getTestSourceDirectory() );
- properties.addList( testSuiteDefinition.getSuiteXmlFiles(), BooterConstants.TEST_SUITE_XML_FILES );
+ properties.setProperty( SOURCE_DIRECTORY, testSuiteDefinition.getTestSourceDirectory() );
+ properties.addList( testSuiteDefinition.getSuiteXmlFiles(), TEST_SUITE_XML_FILES );
TestListResolver methodFilter = testSuiteDefinition.getTestListResolver();
String requestedTest =
methodFilter == null || methodFilter.isEmpty() ? null : methodFilter.getPluginParameterTest();
- properties.setNullableProperty( BooterConstants.REQUESTEDTEST, requestedTest );
- properties.setNullableProperty( BooterConstants.RERUN_FAILING_TESTS_COUNT,
+ properties.setNullableProperty( REQUESTEDTEST, requestedTest );
+ properties.setNullableProperty( RERUN_FAILING_TESTS_COUNT,
String.valueOf( testSuiteDefinition.getRerunFailingTestsCount() ) );
}
DirectoryScannerParameters directoryScannerParameters = booterConfiguration.getDirScannerParams();
if ( directoryScannerParameters != null )
{
- properties.setProperty( BooterConstants.FAILIFNOTESTS,
- String.valueOf( directoryScannerParameters.isFailIfNoTests() ) );
- properties.addList( directoryScannerParameters.getIncludes(), BooterConstants.INCLUDES_PROPERTY_PREFIX );
- properties.addList( directoryScannerParameters.getExcludes(), BooterConstants.EXCLUDES_PROPERTY_PREFIX );
- properties.addList( directoryScannerParameters.getSpecificTests(),
- BooterConstants.SPECIFIC_TEST_PROPERTY_PREFIX );
-
- properties.setProperty( BooterConstants.TEST_CLASSES_DIRECTORY,
- directoryScannerParameters.getTestClassesDirectory() );
+ properties.setProperty( FAILIFNOTESTS, String.valueOf( directoryScannerParameters.isFailIfNoTests() ) );
+ properties.addList( directoryScannerParameters.getIncludes(), INCLUDES_PROPERTY_PREFIX );
+ properties.addList( directoryScannerParameters.getExcludes(), EXCLUDES_PROPERTY_PREFIX );
+ properties.addList( directoryScannerParameters.getSpecificTests(), SPECIFIC_TEST_PROPERTY_PREFIX );
+
+ properties.setProperty( TEST_CLASSES_DIRECTORY, directoryScannerParameters.getTestClassesDirectory() );
}
final RunOrderParameters runOrderParameters = booterConfiguration.getRunOrderParameters();
if ( runOrderParameters != null )
{
- properties.setProperty( BooterConstants.RUN_ORDER, RunOrder.asString( runOrderParameters.getRunOrder() ) );
- properties.setProperty( BooterConstants.RUN_STATISTICS_FILE, runOrderParameters.getRunStatisticsFile() );
+ properties.setProperty( RUN_ORDER, RunOrder.asString( runOrderParameters.getRunOrder() ) );
+ properties.setProperty( RUN_STATISTICS_FILE, runOrderParameters.getRunStatisticsFile() );
}
ReporterConfiguration reporterConfiguration = booterConfiguration.getReporterConfiguration();
boolean rep = reporterConfiguration.isTrimStackTrace();
- properties.setProperty( BooterConstants.ISTRIMSTACKTRACE, rep );
- properties.setProperty( BooterConstants.REPORTSDIRECTORY, reporterConfiguration.getReportsDirectory() );
- ClassLoaderConfiguration classLoaderConfiguration = providerConfiguration.getClassLoaderConfiguration();
- properties.setProperty( BooterConstants.USESYSTEMCLASSLOADER,
- String.valueOf( classLoaderConfiguration.isUseSystemClassLoader() ) );
- properties.setProperty( BooterConstants.USEMANIFESTONLYJAR,
- String.valueOf( classLoaderConfiguration.isUseManifestOnlyJar() ) );
- properties.setProperty( BooterConstants.FAILIFNOTESTS,
- String.valueOf( booterConfiguration.isFailIfNoTests() ) );
- properties.setProperty( BooterConstants.PROVIDER_CONFIGURATION, providerConfiguration.getProviderClassName() );
-
- return SystemPropertyManager.writePropertiesFile( properties,
- forkConfiguration.getTempDirectory(), "surefire",
- forkConfiguration.isDebug() );
+ properties.setProperty( ISTRIMSTACKTRACE, rep );
+ properties.setProperty( REPORTSDIRECTORY, reporterConfiguration.getReportsDirectory() );
+ ClassLoaderConfiguration classLoaderConfig = providerConfiguration.getClassLoaderConfiguration();
+ properties.setProperty( USESYSTEMCLASSLOADER, String.valueOf( classLoaderConfig.isUseSystemClassLoader() ) );
+ properties.setProperty( USEMANIFESTONLYJAR, String.valueOf( classLoaderConfig.isUseManifestOnlyJar() ) );
+ properties.setProperty( FAILIFNOTESTS, String.valueOf( booterConfiguration.isFailIfNoTests() ) );
+ properties.setProperty( PROVIDER_CONFIGURATION, providerConfiguration.getProviderClassName() );
+ List<CommandLineOption> mainCliOptions = booterConfiguration.getMainCliOptions();
+ if ( mainCliOptions != null )
+ {
+ properties.addList( mainCliOptions, MAIN_CLI_OPTIONS );
+ }
+
+ return SystemPropertyManager.writePropertiesFile( properties, forkConfiguration.getTempDirectory(),
+ "surefire", forkConfiguration.isDebug() );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
index c3a2e63..144b38c 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
@@ -22,6 +22,7 @@ package org.apache.maven.plugin.surefire.booterclient;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.maven.surefire.booter.*;
+import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.testset.*;
import org.apache.maven.surefire.util.RunOrder;
@@ -31,6 +32,10 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
+import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
+import static org.apache.maven.surefire.cli.CommandLineOption.REACTOR_FAIL_FAST;
+import static org.apache.maven.surefire.cli.CommandLineOption.SHOW_ERRORS;
+
/**
* Performs roundtrip testing of serialization/deserialization of the ProviderConfiguration
*
@@ -48,6 +53,9 @@ public class BooterDeserializerProviderConfigurationTest
private static final int rerunFailingTestsCount = 3;
+ private final List<CommandLineOption> cli =
+ Arrays.asList( LOGGING_LEVEL_DEBUG, SHOW_ERRORS, REACTOR_FAIL_FAST );
+
private static ClassLoaderConfiguration getForkConfiguration()
{
return new ClassLoaderConfiguration( true, false );
@@ -76,7 +84,7 @@ public class BooterDeserializerProviderConfigurationTest
Assert.assertEquals( includes.get( 1 ), read.getIncludes().get( 1 ) );
Assert.assertEquals( excludes.get( 0 ), read.getExcludes().get( 0 ) );
Assert.assertEquals( excludes.get( 1 ), read.getExcludes().get( 1 ) );
-
+ assertEquals( cli, providerConfiguration.getMainCliOptions() );
}
public void testReporterConfiguration()
@@ -92,6 +100,7 @@ public class BooterDeserializerProviderConfigurationTest
assertTrue( reloaded.getReporterConfiguration().isTrimStackTrace() );
assertNotNull( reloaded.getReporterConfiguration().getReportsDirectory() );
+ assertEquals( cli, providerConfiguration.getMainCliOptions() );
}
public void testTestArtifact()
@@ -101,6 +110,7 @@ public class BooterDeserializerProviderConfigurationTest
Assert.assertEquals( "5.0", reloaded.getTestArtifact().getVersion() );
Assert.assertEquals( "ABC", reloaded.getTestArtifact().getClassifier() );
+ assertEquals( cli, reloaded.getMainCliOptions() );
}
public void testTestRequest()
@@ -126,6 +136,7 @@ public class BooterDeserializerProviderConfigurationTest
Assert.assertEquals( "**/" + aUserRequestedTest, filter.getTestClassPattern() );
Assert.assertEquals( aUserRequestedTestMethod, filter.getTestMethodPattern() );
Assert.assertEquals( rerunFailingTestsCount, testSuiteDefinition.getRerunFailingTestsCount() );
+ assertEquals( cli, reloaded.getMainCliOptions() );
}
public void testTestForFork()
@@ -133,7 +144,7 @@ public class BooterDeserializerProviderConfigurationTest
{
final ProviderConfiguration reloaded = getReloadedProviderConfiguration();
Assert.assertEquals( aTestTyped, reloaded.getTestForFork() );
-
+ assertEquals( cli, reloaded.getMainCliOptions() );
}
public void testTestForForkWithMultipleFiles()
@@ -142,7 +153,7 @@ public class BooterDeserializerProviderConfigurationTest
final ProviderConfiguration reloaded = getReloadedProviderConfigurationForReadFromInStream();
Assert.assertNull( reloaded.getTestForFork() );
Assert.assertTrue( reloaded.isReadTestsFromInStream() );
-
+ assertEquals( cli, reloaded.getMainCliOptions() );
}
public void testFailIfNoTests()
@@ -150,7 +161,7 @@ public class BooterDeserializerProviderConfigurationTest
{
ProviderConfiguration reloaded = getReloadedProviderConfiguration();
assertTrue( reloaded.isFailIfNoTests() );
-
+ assertEquals( cli, reloaded.getMainCliOptions() );
}
private ProviderConfiguration getReloadedProviderConfigurationForReadFromInStream()
@@ -172,6 +183,7 @@ public class BooterDeserializerProviderConfigurationTest
ClassLoaderConfiguration forkConfiguration = getForkConfiguration();
ProviderConfiguration booterConfiguration =
getTestProviderConfiguration( directoryScannerParameters, readTestsFromInStream );
+ assertEquals( cli, booterConfiguration.getMainCliOptions() );
final StartupConfiguration testProviderConfiguration = getTestStartupConfiguration( forkConfiguration );
return saveAndReload( booterConfiguration, testProviderConfiguration, readTestsFromInStream );
}
@@ -225,7 +237,7 @@ public class BooterDeserializerProviderConfigurationTest
RunOrderParameters runOrderParameters = new RunOrderParameters( RunOrder.DEFAULT, null );
return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, true, reporterConfiguration,
new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new HashMap<String, String>(), aTestTyped,
- readTestsFromInStream );
+ readTestsFromInStream, cli );
}
private StartupConfiguration getTestStartupConfiguration( ClassLoaderConfiguration classLoaderConfiguration )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
index 14c5b61..3b85274 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
@@ -21,6 +21,7 @@ package org.apache.maven.plugin.surefire.booterclient;
import junit.framework.TestCase;
import org.apache.maven.surefire.booter.*;
+import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.testset.*;
import org.apache.maven.surefire.util.RunOrder;
@@ -31,6 +32,11 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
+
+import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
+import static org.apache.maven.surefire.cli.CommandLineOption.REACTOR_FAIL_FAST;
+import static org.apache.maven.surefire.cli.CommandLineOption.SHOW_ERRORS;
/**
* Performs roundtrip testing of serialization/deserialization of The StartupConfiguration
@@ -42,6 +48,9 @@ public class BooterDeserializerStartupConfigurationTest
{
private final ClasspathConfiguration classpathConfiguration = createClasspathConfiguration();
+ private final List<CommandLineOption> cli =
+ Arrays.asList( LOGGING_LEVEL_DEBUG, SHOW_ERRORS, REACTOR_FAIL_FAST );
+
public void testProvider()
throws IOException
{
@@ -135,7 +144,7 @@ public class BooterDeserializerStartupConfigurationTest
RunOrderParameters runOrderParameters = new RunOrderParameters( RunOrder.DEFAULT, null );
return new ProviderConfiguration( directoryScannerParameters, runOrderParameters, true, reporterConfiguration,
new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new HashMap<String, String>(),
- BooterDeserializerProviderConfigurationTest.aTestTyped, true );
+ BooterDeserializerProviderConfigurationTest.aTestTyped, true, cli );
}
private StartupConfiguration getTestStartupConfiguration( ClassLoaderConfiguration classLoaderConfiguration )
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/maven-surefire-plugin/src/site/apt/examples/logging.apt.vm
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/site/apt/examples/logging.apt.vm b/maven-surefire-plugin/src/site/apt/examples/logging.apt.vm
new file mode 100644
index 0000000..bd85710
--- /dev/null
+++ b/maven-surefire-plugin/src/site/apt/examples/logging.apt.vm
@@ -0,0 +1,56 @@
+ ------
+ Using Console Logs
+ ------
+ Tibor Digana <ti...@apache.org>
+ ------
+ 2015-06-04
+ ------
+
+ ~~ 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.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Using Console Logs
+
+* Suppressed logs
+
+ Since version 2.19 few lines are suppressed by surefire and failsafe plugin in std/out, namely
+
+ * report directory,
+
+ * Java class of provider,
+
+ * configuration of parallel execution and
+
+ * Java class of TestNG configurator.
+
+ []
+
+ In order to enable detailed logs, use any of CLI Maven option, i.e. -X,--debug,-e,--errors.
+ The result would be e.g.:
+
+
++---+
+[INFO] Surefire report directory: D:\vcs\project\target\surefire-reports
+[INFO] Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider
+[INFO] parallel='none', perCoreThreadCount=true, threadCount=0, useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, threadCountMethods=0, parallelOptimized=true
+Configuring TestNG with: TestNGMapConfigurator
++---+
+
+
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/maven-surefire-plugin/src/site/site.xml
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/site/site.xml b/maven-surefire-plugin/src/site/site.xml
index e67ecb6..1320caf 100644
--- a/maven-surefire-plugin/src/site/site.xml
+++ b/maven-surefire-plugin/src/site/site.xml
@@ -52,6 +52,7 @@
<item name="Selecting Providers" href="examples/providers.html"/>
<item name="New Error Summary" href="newerrorsummary.html"/>
<item name="Fork Options and Parallel Test Execution" href="examples/fork-options-and-parallel-execution.html"/>
+ <item name="Using Console Logs" href="examples/logging.html"/>
</menu>
</body>
</project>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4c91e39..829358c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -211,7 +211,7 @@
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-verifier</artifactId>
- <version>1.5</version>
+ <version>1.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>jmock</groupId>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
index 7dcf1ae..a3ba5db 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
@@ -19,6 +19,7 @@ package org.apache.maven.surefire.booter;
* under the License.
*/
+import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.providerapi.ProviderParameters;
import org.apache.maven.surefire.report.ConsoleLogger;
import org.apache.maven.surefire.report.DefaultDirectConsoleReporter;
@@ -35,6 +36,8 @@ import org.apache.maven.surefire.util.DirectoryScanner;
import org.apache.maven.surefire.util.RunOrderCalculator;
import org.apache.maven.surefire.util.ScanResult;
+import java.util.Collections;
+import java.util.List;
import java.util.Map;
/**
@@ -46,6 +49,12 @@ public class BaseProviderFactory
{
private static final int ROOT_CHANNEL = 0;
+ private final ReporterFactory reporterFactory;
+
+ private final boolean insideFork;
+
+ private List<CommandLineOption> mainCliOptions = Collections.emptyList();
+
private Map<String, String> providerProperties;
private DirectoryScannerParameters directoryScannerParameters;
@@ -60,10 +69,6 @@ public class BaseProviderFactory
private TestArtifactInfo testArtifactInfo;
- private final ReporterFactory reporterFactory;
-
- private final boolean insideFork;
-
public BaseProviderFactory( ReporterFactory reporterFactory, boolean insideFork )
{
this.reporterFactory = reporterFactory;
@@ -174,4 +179,13 @@ public class BaseProviderFactory
this.runOrderParameters = runOrderParameters;
}
+ public List<CommandLineOption> getMainCliOptions()
+ {
+ return mainCliOptions;
+ }
+
+ public void setMainCliOptions( List<CommandLineOption> mainCliOptions )
+ {
+ this.mainCliOptions = mainCliOptions == null ? Collections.<CommandLineOption>emptyList() : mainCliOptions;
+ }
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java b/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java
new file mode 100644
index 0000000..2f82814
--- /dev/null
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/cli/CommandLineOption.java
@@ -0,0 +1,58 @@
+package org.apache.maven.surefire.cli;
+
+/*
+ * 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.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * CLI options.
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.19
+ * @see http://books.sonatype.com/mvnref-book/reference/running-sect-options.html
+ */
+public enum CommandLineOption
+{
+ REACTOR_FAIL_FAST , REACTOR_FAIL_AT_END, REACTOR_FAIL_NEVER,
+ SHOW_ERRORS,
+ LOGGING_LEVEL_WARN, LOGGING_LEVEL_INFO, LOGGING_LEVEL_ERROR, LOGGING_LEVEL_DEBUG;
+
+ public static List<CommandLineOption> fromStrings( Collection<String> elements )
+ {
+ List<CommandLineOption> options = new ArrayList<CommandLineOption>( elements.size() );
+ for ( String element : elements )
+ {
+ options.add( valueOf( element ) );
+ }
+ return options;
+ }
+
+ public static List<String> toStrings( Collection<CommandLineOption> options )
+ {
+ List<String> elements = new ArrayList<String>( options.size() );
+ for ( CommandLineOption option : options )
+ {
+ elements.add( option.name() );
+ }
+ return elements;
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
----------------------------------------------------------------------
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
index 51b40f0..cb6da9a 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
@@ -19,6 +19,7 @@ package org.apache.maven.surefire.providerapi;
* under the License.
*/
+import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.report.ConsoleLogger;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.report.ReporterFactory;
@@ -29,6 +30,7 @@ import org.apache.maven.surefire.util.DirectoryScanner;
import org.apache.maven.surefire.util.RunOrderCalculator;
import org.apache.maven.surefire.util.ScanResult;
+import java.util.List;
import java.util.Map;
/**
@@ -129,4 +131,5 @@ public interface ProviderParameters
*/
TestArtifactInfo getTestArtifactInfo();
+ List<CommandLineOption> getMainCliOptions();
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
index f55bbb2..be5c4c3 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
@@ -52,4 +52,5 @@ public final class BooterConstants
public static final String FORKTESTSET = "forkTestSet";
public static final String FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM = "preferTestsFromInStream";
public static final String RERUN_FAILING_TESTS_COUNT = "rerunFailingTestsCount";
+ public static final String MAIN_CLI_OPTIONS = "mainCliOptions";
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
index 1ce2330..c5f7c03 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
@@ -22,6 +22,7 @@ package org.apache.maven.surefire.booter;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Collection;
import java.util.List;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.testset.DirectoryScannerParameters;
@@ -32,6 +33,7 @@ import org.apache.maven.surefire.testset.TestRequest;
// CHECKSTYLE_OFF: imports
import static org.apache.maven.surefire.booter.BooterConstants.*;
+import static org.apache.maven.surefire.cli.CommandLineOption.*;
/**
* Knows how to serialize and deserialize the booter configuration.
@@ -96,10 +98,12 @@ public class BooterDeserializer
ReporterConfiguration reporterConfiguration =
new ReporterConfiguration( reportsDirectory, properties.getBooleanObjectProperty( ISTRIMSTACKTRACE ) );
+ Collection<String> cli = properties.getStringList( MAIN_CLI_OPTIONS );
+
return new ProviderConfiguration( dirScannerParams, runOrderParameters,
properties.getBooleanProperty( FAILIFNOTESTS ), reporterConfiguration, testNg,
testSuiteDefinition, properties.getProperties(), typeEncodedTestForFork,
- preferTestsFromInStream );
+ preferTestsFromInStream, fromStrings( cli ) );
}
public StartupConfiguration getProviderConfiguration()
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
index 1b122ce..f59461a 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
@@ -235,6 +235,7 @@ public class ForkedBooter
bpf.setProviderProperties( providerConfiguration.getProviderProperties() );
bpf.setRunOrderParameters( providerConfiguration.getRunOrderParameters() );
bpf.setDirectoryScannerParameters( providerConfiguration.getDirScannerParams() );
+ bpf.setMainCliOptions( providerConfiguration.getMainCliOptions() );
return (SurefireProvider) ReflectionUtils.instantiateOneArg( classLoader,
startupConfiguration1.getActualClassName(),
ProviderParameters.class, bpf );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
----------------------------------------------------------------------
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
index 2ee0870..61f204d 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
@@ -22,6 +22,8 @@ package org.apache.maven.surefire.booter;
import java.io.File;
import java.util.List;
import java.util.Map;
+
+import org.apache.maven.surefire.cli.CommandLineOption;
import org.apache.maven.surefire.report.ReporterConfiguration;
import org.apache.maven.surefire.testset.DirectoryScannerParameters;
import org.apache.maven.surefire.testset.RunOrderParameters;
@@ -62,12 +64,15 @@ public class ProviderConfiguration
private final boolean readTestsFromInStream;
+ private final List<CommandLineOption> mainCliOptions;
+
@SuppressWarnings( "checkstyle:parameternumber" )
public ProviderConfiguration( DirectoryScannerParameters directoryScannerParameters,
RunOrderParameters runOrderParameters, boolean failIfNoTests,
ReporterConfiguration reporterConfiguration, TestArtifactInfo testArtifact,
TestRequest testSuiteDefinition, Map<String, String> providerProperties,
- TypeEncodedValue typeEncodedTestSet, boolean readTestsFromInStream )
+ TypeEncodedValue typeEncodedTestSet, boolean readTestsFromInStream,
+ List<CommandLineOption> mainCliOptions )
{
this.runOrderParameters = runOrderParameters;
this.providerProperties = providerProperties;
@@ -78,9 +83,9 @@ public class ProviderConfiguration
this.failIfNoTests = failIfNoTests;
this.forkTestSet = typeEncodedTestSet;
this.readTestsFromInStream = readTestsFromInStream;
+ this.mainCliOptions = mainCliOptions;
}
-
public ReporterConfiguration getReporterConfiguration()
{
return reporterConfiguration;
@@ -142,4 +147,9 @@ public class ProviderConfiguration
{
return readTestsFromInStream;
}
+
+ public List<CommandLineOption> getMainCliOptions()
+ {
+ return mainCliOptions;
+ }
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java
index d2d0098..5aee1a8 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47ParallelIT.java
@@ -534,6 +534,7 @@ public class JUnit47ParallelIT
private SurefireLauncher unpack()
{
- return unpack( "junit47-parallel" );
+ return unpack( "junit47-parallel" )
+ .showErrorStackTraces();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java
index befae1b..b057a34 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java
@@ -32,7 +32,7 @@ import org.junit.Test;
public class TestMethodPatternIT
extends SurefireJUnit4IntegrationTestCase
{
- private static final String RUNNING_WITH_JUNIT48 = "parallel='none', perCoreThreadCount=true, threadCount=0";
+ private static final String RUNNING_WITH_PROVIDER47 = "parallel='none', perCoreThreadCount=true, threadCount=0";
public OutputValidator runMethodPattern( String projectName, String... goals )
{
@@ -41,7 +41,9 @@ public class TestMethodPatternIT
{
launcher.addGoal( goal );
}
- return launcher.executeTest().assertTestSuiteResults( 2, 0, 0, 0 );
+ return launcher.showErrorStackTraces().debugLogging()
+ .executeTest()
+ .assertTestSuiteResults( 2, 0, 0, 0 );
}
@Test
@@ -60,7 +62,7 @@ public class TestMethodPatternIT
public void testJUnit48Provider47()
{
runMethodPattern( "junit48-method-pattern", "-P surefire-junit47" )
- .verifyTextInLog( RUNNING_WITH_JUNIT48 );
+ .verifyTextInLog( RUNNING_WITH_PROVIDER47 );
}
@Test
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java
index 760b330..cb773cd 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java
@@ -34,7 +34,7 @@ public class TestMultipleMethodsIT
extends SurefireJUnit4IntegrationTestCase
{
- private static final String RUNNING_WITH_JUNIT48 = "parallel='none', perCoreThreadCount=true, threadCount=0";
+ private static final String RUNNING_WITH_PROVIDER47 = "parallel='none', perCoreThreadCount=true, threadCount=0";
public OutputValidator multipleMethod( String projectName, String... goals )
throws Exception
@@ -44,7 +44,9 @@ public class TestMultipleMethodsIT
{
launcher.addGoal( goal );
}
- return launcher.executeTest().verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 );
+ return launcher.showErrorStackTraces().debugLogging()
+ .executeTest()
+ .verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 );
}
@Test
@@ -66,7 +68,7 @@ public class TestMultipleMethodsIT
throws Exception
{
multipleMethod( "junit48-multiple-methods", "-P surefire-junit47" )
- .verifyTextInLog( RUNNING_WITH_JUNIT48 );
+ .verifyTextInLog( RUNNING_WITH_PROVIDER47 );
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java
index b29064a..d7b7088 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java
@@ -32,7 +32,7 @@ import org.junit.Test;
public class TestSingleMethodIT
extends SurefireJUnit4IntegrationTestCase
{
- private static final String RUNNING_WITH_JUNIT48 = "parallel='none', perCoreThreadCount=true, threadCount=0";
+ private static final String RUNNING_WITH_PROVIDER47 = "parallel='none', perCoreThreadCount=true, threadCount=0";
public OutputValidator singleMethod( String projectName, String... goals )
throws Exception
@@ -42,7 +42,10 @@ public class TestSingleMethodIT
{
launcher.addGoal( goal );
}
- return launcher.executeTest().verifyErrorFreeLog().assertTestSuiteResults( 1, 0, 0, 0 );
+ return launcher.showErrorStackTraces().debugLogging()
+ .executeTest()
+ .verifyErrorFreeLog()
+ .assertTestSuiteResults( 1, 0, 0, 0 );
}
@Test
@@ -64,7 +67,7 @@ public class TestSingleMethodIT
throws Exception
{
singleMethod( "junit48-single-method", "-P surefire-junit47" )
- .verifyTextInLog( RUNNING_WITH_JUNIT48 );
+ .verifyTextInLog( RUNNING_WITH_PROVIDER47 );
}
@Test
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
index 8d4a385..ef5dc33 100755
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
@@ -58,17 +58,25 @@ public class MavenLauncher
private final String suffix;
+ private final String[] cli;
+
private boolean expectFailure;
- public MavenLauncher( Class testClass, String resourceName, String suffix )
+ public MavenLauncher( Class testClass, String resourceName, String suffix, String[] cli )
{
this.testCaseBeingRun = testClass;
this.resourceName = resourceName;
this.suffix = suffix != null ? suffix : "";
+ this.cli = cli == null ? null : cli.clone();
resetGoals();
resetCliOptions();
}
+ public MavenLauncher( Class testClass, String resourceName, String suffix )
+ {
+ this( testClass, resourceName, suffix, null );
+ }
+
public File getUnpackedAt()
{
return ensureUnpacked();
@@ -144,7 +152,7 @@ public class MavenLauncher
throws VerificationException
{
MavenLauncher mavenLauncher =
- new MavenLauncher( testCaseBeingRun, resourceName + File.separator + subProject, suffix );
+ new MavenLauncher( testCaseBeingRun, resourceName + File.separator + subProject, suffix, cli );
mavenLauncher.unpackedAt = new File( ensureUnpacked(), subProject );
return mavenLauncher;
}
@@ -382,7 +390,10 @@ public class MavenLauncher
{
try
{
- this.verifier = new Verifier( ensureUnpacked().getAbsolutePath() );
+ verifier =
+ cli == null
+ ? new Verifier( ensureUnpacked().getAbsolutePath(), null, false )
+ : new Verifier( ensureUnpacked().getAbsolutePath(), null, false, cli );
}
catch ( VerificationException e )
{
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java
index ff49392..c300abf 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireJUnit4IntegrationTestCase.java
@@ -46,10 +46,15 @@ public abstract class SurefireJUnit4IntegrationTestCase
return unpack( getClass(), sourceName, suffix );
}
- public static SurefireLauncher unpack( Class testClass, String sourceName, String suffix )
+ public static SurefireLauncher unpack( Class testClass, String sourceName, String suffix, String[] cli )
{
- MavenLauncher mavenLauncher = new MavenLauncher( testClass, sourceName, suffix );
+ MavenLauncher mavenLauncher = new MavenLauncher( testClass, sourceName, suffix, cli );
return new SurefireLauncher( mavenLauncher );
}
+ public static SurefireLauncher unpack( Class testClass, String sourceName, String suffix )
+ {
+ return unpack( testClass, sourceName, suffix, null );
+ }
+
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java
index fbf87d5..58e951a 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1152RerunFailingTestsInSuiteIT.java
@@ -32,7 +32,7 @@ import org.junit.Test;
public class Surefire1152RerunFailingTestsInSuiteIT
extends SurefireJUnit4IntegrationTestCase
{
- private static final String RUNNING_WITH_JUNIT48 =
+ private static final String RUNNING_WITH_PROVIDER47 =
"Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider";
public OutputValidator runMethodPattern( String projectName, String... goals )
@@ -42,7 +42,7 @@ public class Surefire1152RerunFailingTestsInSuiteIT
{
launcher.addGoal( goal );
}
- OutputValidator outputValidator = launcher.executeVerify();
+ OutputValidator outputValidator = launcher.showErrorStackTraces().debugLogging().executeVerify();
outputValidator.assertTestSuiteResults( 3, 0, 0, 0, 3 );
outputValidator.assertIntegrationTestSuiteResults( 1, 0, 0, 0 );
return outputValidator;
@@ -57,7 +57,8 @@ public class Surefire1152RerunFailingTestsInSuiteIT
@Test
public void testJUnit48Provider47()
{
- runMethodPattern( "surefire-1152-rerunFailingTestsCount-suite", "-P surefire-junit47" ).verifyTextInLog( RUNNING_WITH_JUNIT48 );
+ runMethodPattern( "surefire-1152-rerunFailingTestsCount-suite", "-P surefire-junit47" )
+ .verifyTextInLog( RUNNING_WITH_PROVIDER47 );
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java
new file mode 100644
index 0000000..6f8bed9
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1158RemoveInfoLinesIT.java
@@ -0,0 +1,145 @@
+package org.apache.maven.surefire.its.jiras;
+/*
+ * 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 org.apache.maven.surefire.its.Not2xCompatible;
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireVerifierException;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+
+import static org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase.unpack;
+import static org.junit.runners.Parameterized.*;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1158}
+ * @since 2.19
+ */
+@RunWith( Parameterized.class )
+@Category( Not2xCompatible.class )
+public class Surefire1158RemoveInfoLinesIT
+{
+
+ @Parameters(name = "{0}")
+ public static Iterable<Object[]> data()
+ {
+ ArrayList<Object[]> args = new ArrayList<Object[]>();
+ args.add( new Object[] { "junit-option-ff", "JUnitTest", "-ff", "surefire-junit47", false, true } );
+ args.add( new Object[] { "testng-option-ff", "TestNGSuiteTest", "-ff", "surefire-testng", false, false } );
+ args.add( new Object[] { "junit-option-X", "JUnitTest", "-X", "surefire-junit47", true, true } );
+ args.add( new Object[] { "testng-option-X", "TestNGSuiteTest", "-X", "surefire-testng", true, false } );
+ args.add( new Object[] { "junit-option-e", "JUnitTest", "-e", "surefire-junit47", true, true } );
+ args.add( new Object[] { "testng-option-e", "TestNGSuiteTest", "-e", "surefire-testng", true, false } );
+ return args;
+ }
+
+ @Parameter(0)
+ public String description;
+
+ @Parameter(1)
+ public String testToRun;
+
+ @Parameter(2)
+ public String cliOption;
+
+ @Parameter(3)
+ public String provider;
+
+ @Parameter(4)
+ public boolean printsInfoLines;
+
+ @Parameter(5)
+ public boolean isJUnit;
+
+ @Test
+ public void shouldRunWithCliOption()
+ throws Exception
+ {
+ OutputValidator validator = assertTest();
+ if ( isJUnit )
+ {
+ assertJUnitTestLogs( validator );
+ }
+ else
+ {
+ assertTestNGTestLogs( validator );
+ }
+ }
+
+ private OutputValidator assertTest()
+ throws Exception
+ {
+ final String[] cli = {"--batch-mode"};
+ return unpack( getClass(), "/surefire-1158-remove-info-lines", "_" + description, cli )
+ .sysProp( "provider", provider ).addGoal( cliOption ).setTestToRun( testToRun )
+ .executeTest()
+ .verifyErrorFreeLog().assertTestSuiteResults( 1, 0, 0, 0 );
+ }
+
+ private void assertJUnitTestLogs( OutputValidator validator )
+ {
+ try
+ {
+ validator.verifyTextInLog( "Surefire report directory:" );
+ validator.verifyTextInLog( "Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider" );
+ validator.verifyTextInLog( "parallel='none', perCoreThreadCount=true, threadCount=0, "
+ + "useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, "
+ + "threadCountMethods=0, parallelOptimized=true" );
+ if ( !printsInfoLines )
+ {
+ fail();
+ }
+ }
+ catch ( SurefireVerifierException e )
+ {
+ if ( printsInfoLines )
+ {
+ fail();
+ }
+ }
+ }
+
+ private void assertTestNGTestLogs( OutputValidator validator )
+ {
+ try
+ {
+ validator.verifyTextInLog( "Surefire report directory:" );
+ validator.verifyTextInLog( "Using configured provider org.apache.maven.surefire.testng.TestNGProvider" );
+ validator.verifyTextInLog( "Configuring TestNG with: TestNGMapConfigurator" );
+ if ( !printsInfoLines )
+ {
+ fail();
+ }
+ }
+ catch ( SurefireVerifierException e )
+ {
+ if ( printsInfoLines )
+ {
+ fail();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
index 48ed050..ecf01a8 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
@@ -37,43 +37,58 @@ public class Surefire141PluggableProvidersIT
public static void installProvider()
throws VerificationException
{
- unpack( Surefire141PluggableProvidersIT.class, "surefire-141-pluggableproviders-provider", "prov" ).executeInstall();
+ unpack( Surefire141PluggableProvidersIT.class, "surefire-141-pluggableproviders-provider", "prov" )
+ .executeInstall();
}
@Test
public void pluggableProviderPresent()
throws Exception
{
- unpack( "surefire-141-pluggableproviders" ).maven().showExceptionMessages().executeTest().verifyTextInLog(
- "Using configured provider org.apache.maven.surefire.testprovider.TestProvider" ).verifyTextInLog(
- "Using configured provider org.apache.maven.surefire.junit.JUnit3Provider" ).verifyErrorFreeLog();
+ unpack( "surefire-141-pluggableproviders" )
+ .maven()
+ .showExceptionMessages()
+ .debugLogging()
+ .executeTest()
+ .verifyTextInLog( "Using configured provider org.apache.maven.surefire.testprovider.TestProvider" )
+ .verifyTextInLog( "Using configured provider org.apache.maven.surefire.junit.JUnit3Provider" )
+ .verifyErrorFreeLog();
}
@Test
public void invokeRuntimeException()
throws Exception
{
- unpack( "surefire-141-pluggableproviders" ).sysProp( "invokeCrash",
- "runtimeException" ).maven().withFailure().executeTest().verifyTextInLog(
- "Let's fail with a runtimeException" );
+ unpack( "surefire-141-pluggableproviders" )
+ .sysProp( "invokeCrash", "runtimeException" )
+ .maven()
+ .withFailure()
+ .executeTest()
+ .verifyTextInLog( "Let's fail with a runtimeException" );
}
@Test
public void invokeReporterException()
throws Exception
{
- unpack( "surefire-141-pluggableproviders" ).sysProp( "invokeCrash",
- "reporterException" ).maven().withFailure().executeTest().verifyTextInLog(
- "Let's fail with a reporterexception" );
+ unpack( "surefire-141-pluggableproviders" )
+ .sysProp( "invokeCrash", "reporterException" )
+ .maven()
+ .withFailure()
+ .executeTest()
+ .verifyTextInLog( "Let's fail with a reporterexception" );
}
@Test
- public void constructorReuntimeException()
+ public void constructorRuntimeException()
throws Exception
{
- unpack( "surefire-141-pluggableproviders" ).sysProp( "constructorCrash",
- "runtimeException" ).maven().withFailure().executeTest().verifyTextInLog(
- "Let's fail with a runtimeException" );
+ unpack( "surefire-141-pluggableproviders" )
+ .sysProp( "constructorCrash", "runtimeException" )
+ .maven()
+ .withFailure()
+ .executeTest()
+ .verifyTextInLog( "Let's fail with a runtimeException" );
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67e6606d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java
index a847b00..3287ab4 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire408ManualProviderSelectionIT.java
@@ -31,9 +31,12 @@ public class Surefire408ManualProviderSelectionIT
extends SurefireJUnit4IntegrationTestCase
{
@Test
- public void testPaallelBuildResultCount()
+ public void testParallelBuildResultCount()
{
- unpack( "/surefire-408-manual-provider-selection" ).showErrorStackTraces().executeTest().verifyTextInLog(
- "Using configured provider org.apache.maven.surefire.junit.JUnit3Provider" );
+ unpack( "/surefire-408-manual-provider-selection" )
+ .showErrorStackTraces()
+ .debugLogging()
+ .executeTest()
+ .verifyTextInLog( "Using configured provider org.apache.maven.surefire.junit.JUnit3Provider" );
}
}
\ No newline at end of file