maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dfabul...@apache.org
Subject svn commit: r652695 - in /maven/surefire/trunk: maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgSuiteXmlSingleTest.java
Date Thu, 01 May 2008 22:30:17 GMT
Author: dfabulich
Date: Thu May  1 15:30:17 2008
New Revision: 652695

URL: http://svn.apache.org/viewvc?rev=652695&view=rev
Log:
[SUREFIRE-492] Allow "test" parameter to override suiteXmlFiles

Added:
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgSuiteXmlSingleTest.java
Modified:
    maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java

Modified: maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=652695&r1=652694&r2=652695&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
(original)
+++ maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Thu May  1 15:30:17 2008
@@ -180,11 +180,11 @@
     private File testSourceDirectory;
 
     /**
-     * Specify this parameter to run individual tests by file name, overriding the <code>includes</code>
-     * and <code>excludes</code> parameters.  Each pattern you specify here will
be used to create an 
+     * Specify this parameter to run individual tests by file name, overriding the <code>includes/excludes</code>
+     * parameters.  Each pattern you specify here will be used to create an 
      * include pattern formatted like <code>**&#47;${test}.java</code>, so
you can just type "-Dtest=MyTest"
-     * to run a single test called "foo/MyTest.java".  This parameter is ignored if
-     * TestNG suiteXmlFiles are specified.
+     * to run a single test called "foo/MyTest.java".  This parameter will override the TestNG
suiteXmlFiles
+     * parameter.
      * 
      * @parameter expression="${test}"
      */
@@ -383,8 +383,9 @@
     private String excludedGroups;
 
     /**
-     * (TestNG only) List of TestNG suite xml file locations, seperated by commas. It should
be noted that if suiteXmlFiles is
-     * specified, <b>no</b> other tests will be run, ignoring other parameters,
like includes and excludes.
+     * (TestNG only) List of TestNG suite xml file locations, seperated by commas. Note that
suiteXmlFiles is incompatible
+     * with several other parameters on this plugin, like includes/excludes.  This parameter
is ignored if
+     * the "test" parameter is specified (allowing you to run a single test instead of an
entire suite).
      * 
      * @parameter
      * @since 2.2
@@ -697,7 +698,7 @@
             throw new MojoExecutionException( "Error to resolving surefire provider dependency:
" + e.getMessage(), e );
         }
 
-        if ( suiteXmlFiles != null && suiteXmlFiles.length > 0 )
+        if ( suiteXmlFiles != null && suiteXmlFiles.length > 0 && test
== null )
         {
             if ( testNgArtifact == null )
             {

Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgSuiteXmlSingleTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgSuiteXmlSingleTest.java?rev=652695&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgSuiteXmlSingleTest.java
(added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgSuiteXmlSingleTest.java
Thu May  1 15:30:17 2008
@@ -0,0 +1,41 @@
+package org.apache.maven.surefire.its;
+
+
+import junit.framework.TestCase;
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Use -Dtest to run a single TestNG test, overriding the suite XML parameter.
+ * 
+ * @author <a href="mailto:dfabulich@apache.org">Dan Fabulich</a>
+ * 
+ */
+public class TestNgSuiteXmlSingleTest
+    extends TestCase
+{
+    public void testTestNGSuite()
+        throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/testng-twoTestCaseSuite"
);
+
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        List goals = new ArrayList();
+        goals.add( "test" );
+        goals.add( "-Dtest=TestNGTestTwo" );
+        verifier.executeGoals( goals );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+
+        List reports = HelperAssertions.extractReports( ( new File[] { testDir } ) );
+        ITSuiteResults results = HelperAssertions.parseReportList( reports );
+        HelperAssertions.assertTestSuiteResults( 1, 0, 0, 0, results );
+    }
+
+}



Mime
View raw message