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/10/13 00:48:26 UTC
[1/2] maven-surefire git commit: [SUREFIRE] IT refactoring
Repository: maven-surefire
Updated Branches:
refs/heads/master 8b78618bc -> 97092f717
[SUREFIRE] IT refactoring
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/827dd1a2
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/827dd1a2
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/827dd1a2
Branch: refs/heads/master
Commit: 827dd1a26f96b027835d4d98e925f189012bb884
Parents: 8b78618
Author: Tibor17 <ti...@lycos.com>
Authored: Tue Oct 13 00:44:59 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Tue Oct 13 00:44:59 2015 +0200
----------------------------------------------------------------------
.../org/apache/maven/surefire/its/CheckTestNgVersionsIT.java | 4 +---
.../java/org/apache/maven/surefire/its/TwoTestCasesIT.java | 7 +++----
.../its/jiras/Surefire224WellFormedXmlFailuresIT.java | 4 +---
3 files changed, 5 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/827dd1a2/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java
index fb3a51e..49c0be7 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgVersionsIT.java
@@ -19,7 +19,6 @@ package org.apache.maven.surefire.its;
* under the License.
*/
-import java.io.File;
import java.util.List;
import org.apache.maven.plugins.surefire.report.ReportTestSuite;
@@ -186,8 +185,7 @@ public class CheckTestNgVersionsIT
if ( validateRunOrder )
{
// assert correct run order of tests
- List<ReportTestSuite> report =
- HelperAssertions.extractReports( new File[] { outputValidator.getBaseDir() } );
+ List<ReportTestSuite> report = HelperAssertions.extractReports( outputValidator.getBaseDir() );
assertEquals( 3, report.size() );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/827dd1a2/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java
index 758c506..eca2fb0 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TwoTestCasesIT.java
@@ -19,7 +19,6 @@ package org.apache.maven.surefire.its;
* under the License.
*/
-import java.io.File;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -54,7 +53,7 @@ public class TwoTestCasesIT
{
final OutputValidator outputValidator = unpack( "junit-twoTestCaseSuite" ).executeTest();
outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 2, 0, 0, 0 );
- List<ReportTestSuite> reports = HelperAssertions.extractReports( new File[]{ outputValidator.getBaseDir() } );
+ List<ReportTestSuite> reports = HelperAssertions.extractReports( outputValidator.getBaseDir() );
Set<String> classNames = extractClassNames( reports );
assertContains( classNames, "junit.twoTestCaseSuite.BasicTest" );
assertContains( classNames, "junit.twoTestCaseSuite.TestTwo" );
@@ -90,7 +89,7 @@ public class TwoTestCasesIT
outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 2, 0, 0, 0 );
List<ReportTestSuite> reports =
- HelperAssertions.extractReports( ( new File[]{ outputValidator.getBaseDir() } ) );
+ HelperAssertions.extractReports( outputValidator.getBaseDir() );
Set<String> classNames = extractClassNames( reports );
assertContains( classNames, "twoTestCaseSuite.BasicTest" );
assertContains( classNames, "twoTestCaseSuite.Junit4TestTwo" );
@@ -105,7 +104,7 @@ public class TwoTestCasesIT
{
final OutputValidator outputValidator = unpack( "testng-twoTestCaseSuite" ).executeTest();
outputValidator.verifyErrorFreeLog().assertTestSuiteResults( 2, 0, 0, 0 );
- List<ReportTestSuite> reports = HelperAssertions.extractReports( new File[]{ outputValidator.getBaseDir() } );
+ List<ReportTestSuite> reports = HelperAssertions.extractReports( outputValidator.getBaseDir() );
Set<String> classNames = extractClassNames( reports );
assertContains( classNames, "testng.two.TestNGTestTwo" );
assertContains( classNames, "testng.two.TestNGSuiteTest" );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/827dd1a2/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java
index 1118b85..1bdb3cb 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire224WellFormedXmlFailuresIT.java
@@ -26,7 +26,6 @@ import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Test;
-import java.io.File;
import java.util.List;
import static org.junit.Assert.assertEquals;
@@ -47,8 +46,7 @@ public class Surefire224WellFormedXmlFailuresIT
outputValidator.assertTestSuiteResults( 4, 0, 4, 0 );
- ReportTestSuite suite =
- HelperAssertions.extractReports( ( new File[]{ outputValidator.getBaseDir() } ) ).get( 0 );
+ ReportTestSuite suite = HelperAssertions.extractReports( outputValidator.getBaseDir() ).get( 0 );
List<org.apache.maven.plugins.surefire.report.ReportTestCase> testCases = suite.getTestCases();
assertEquals( "Wrong number of test case objects", 4, testCases.size() );
ReportTestCase testQuote = null, testLower = null, testGreater = null, testU0000 = null;
[2/2] maven-surefire git commit: [SUREFIRE-919] TestNG plugin fails
to apply 'verbose' setting from TestNG.xml
Posted by ti...@apache.org.
[SUREFIRE-919] TestNG plugin fails to apply 'verbose' setting from TestNG.xml
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/97092f71
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/97092f71
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/97092f71
Branch: refs/heads/master
Commit: 97092f71714dacaab7a8498142083bc5d87bd4bf
Parents: 827dd1a
Author: Tibor17 <ti...@lycos.com>
Authored: Tue Oct 13 00:48:01 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Tue Oct 13 00:48:01 2015 +0200
----------------------------------------------------------------------
.../src/site/apt/examples/testng.apt.vm | 35 ++++++++++++++++++--
.../surefire/its/CheckTestNgReportTestIT.java | 28 ++++++++++++++++
.../src/test/resources/testng-simple/pom.xml | 7 ++++
.../maven/surefire/testng/TestNGExecutor.java | 29 ++++++++++++----
4 files changed, 90 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/97092f71/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm b/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
index 14d3f62..11bf3be 100644
--- a/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/testng.apt.vm
@@ -38,7 +38,7 @@ Using TestNG
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>6.8.8</version>
+ <version>6.9.8</version>
<scope>test</scope>
</dependency>
[...]
@@ -171,7 +171,7 @@ Using TestNG
This is particularly useful for slow tests that can have high concurrency, or to quickly and roughly assess the independence
and thread safety of your tests and code.
- TestNG 5.10 or higher allows you to run methods in parallel test using data provider.
+ TestNG 5.10 and plugin version 2.19 or higher allows you to run methods in parallel test using data provider.
+---+
</plugins>
@@ -197,7 +197,7 @@ Using TestNG
</plugins>
+---+
- TestNG 6.9.8 (JRE 1.7) or higher allows you to run suites in parallel.
+ TestNG 6.9.8 (JRE 1.7) and plugin version 2.19 or higher allows you to run suites in parallel.
+---+
</plugins>
@@ -278,6 +278,35 @@ Using TestNG
<<<src/test/java>>>. You can filter test artifacts by the parameter <<<dependenciesToScan>>> to load its classes
in current ClassLoader of surefire-testng provider.
+* The level of verbosity
+
+ Since the plugin version 2.19 or higher the verbosity level can be configured in provider property
+ <<<surefire.testng.verbose>>>. The verbosity level is between 0 and 10 where 10 is the most detailed.
+ You can specify -1 and this will put TestNG in debug mode (no longer slicing off stack traces and all).
+ The default level is 0.
+
++---+
+</plugins>
+ [...]
+ <plugin>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>${project.artifactId}</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ [...]
+ <properties>
+ <property>
+ <name>surefire.testng.verbose</name>
+ <value>10</value>
+ </property>
+ </properties>
+ [...]
+ </configuration>
+ </plugin>
+ [...]
+</plugins>
++---+
+
* Running TestNG and JUnit Tests
TestNG 6.5.1 and higher provides support to run TestNG and JUnit 4.x in current Maven project. All you need
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/97092f71/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java
index ff6ee58..1bad84b 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java
@@ -23,6 +23,9 @@ import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Test;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+
/**
* Test surefire-report on TestNG test
*
@@ -39,4 +42,29 @@ public class CheckTestNgReportTestIT
unpack( "/testng-simple" ).addSurefireReportGoal().executeCurrentGoals().verifyErrorFree( 3 );
outputValidator.getSiteFile( "surefire-report.html" ).assertFileExists();
}
+
+ @Test
+ public void shouldNotBeVerbose()
+ throws Exception
+ {
+ unpack( "/testng-simple" )
+ .sysProp( "testNgVersion", "5.10" )
+ .sysProp( "testNgClassifier", "jdk15" )
+ .executeTest()
+ .verifyErrorFreeLog()
+ .assertThatLogLine( containsString( "[Parser] Running:" ), is( 0 ) );
+ }
+
+ @Test
+ public void shouldBeVerbose()
+ throws Exception
+ {
+ unpack( "/testng-simple" )
+ .sysProp( "testNgVersion", "5.10" )
+ .sysProp( "testNgClassifier", "jdk15" )
+ .sysProp( "surefire.testng.verbose", "10" )
+ .executeTest()
+ .verifyErrorFreeLog()
+ .assertThatLogLine( containsString( "[Parser] Running:" ), is( 1 ) );
+ }
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/97092f71/surefire-integration-tests/src/test/resources/testng-simple/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/testng-simple/pom.xml b/surefire-integration-tests/src/test/resources/testng-simple/pom.xml
index d85d82f..fffad18 100644
--- a/surefire-integration-tests/src/test/resources/testng-simple/pom.xml
+++ b/surefire-integration-tests/src/test/resources/testng-simple/pom.xml
@@ -74,6 +74,7 @@
<properties>
<testNgVersion>5.7</testNgVersion>
+ <surefire.testng.verbose>0</surefire.testng.verbose>
</properties>
<build>
@@ -93,6 +94,12 @@
<version>${surefire.version}</version>
<configuration>
<runOrder>reversealphabetical</runOrder>
+ <properties>
+ <property>
+ <name>surefire.testng.verbose</name>
+ <value>${surefire.testng.verbose}</value>
+ </property>
+ </properties>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/97092f71/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
index 5a91db0..05f7871 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
@@ -127,7 +127,8 @@ public class TestNGExecutor
testng.setXmlSuites( xmlSuites );
configurator.configure( testng, options );
- postConfigure( testng, testSourceDirectory, reportManager, suite, reportsDirectory, skipAfterFailureCount );
+ postConfigure( testng, testSourceDirectory, reportManager, suite, reportsDirectory, skipAfterFailureCount,
+ extractVerboseLevel( options ) );
testng.run();
}
@@ -275,7 +276,8 @@ public class TestNGExecutor
TestNG testng = new TestNG( true );
Configurator configurator = getConfigurator( options.get( "testng.configurator" ) );
configurator.configure( testng, options );
- postConfigure( testng, testSourceDirectory, reportManager, suite, reportsDirectory, skipAfterFailureCount );
+ postConfigure( testng, testSourceDirectory, reportManager, suite, reportsDirectory, skipAfterFailureCount,
+ extractVerboseLevel( options ) );
testng.setTestSuites( suiteFiles );
testng.run();
}
@@ -301,11 +303,11 @@ public class TestNGExecutor
}
private static void postConfigure( TestNG testNG, String sourcePath, final RunListener reportManager,
- TestNgTestSuite suite, File reportsDirectory, int skipAfterFailureCount )
- throws TestSetFailedException
+ TestNgTestSuite suite, File reportsDirectory, int skipAfterFailureCount,
+ int verboseLevel )
{
- // turn off all TestNG output
- testNG.setVerbose( 0 );
+ // 0 (default): turn off all TestNG output
+ testNG.setVerbose( verboseLevel );
TestNGReporter reporter = createTestNGReporter( reportManager, suite );
testNG.addListener( (Object) reporter );
@@ -371,4 +373,19 @@ public class TestNGExecutor
}
}
+ private static int extractVerboseLevel( Map<String, String> options )
+ throws TestSetFailedException
+ {
+ try
+ {
+ String verbose = options.get( "surefire.testng.verbose" );
+ return verbose == null ? 0 : Integer.parseInt( verbose );
+ }
+ catch ( NumberFormatException e )
+ {
+ throw new TestSetFailedException( "Provider property 'surefire.testng.verbose' should refer to "
+ + "number -1 (debug mode), 0, 1 .. 10 (most detailed).", e );
+ }
+ }
+
}