Author: olamy
Date: Tue Apr 5 10:40:34 2011
New Revision: 1088960
URL: http://svn.apache.org/viewvc?rev=1088960&view=rev
Log:
[SUREFIRE-722] testng : using -Dtest=myClass#myMethod doesn't execute methods
marked @Before* @After*
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternBeforeIT.java
(with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml
(with props)
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/test/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/test/java/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/test/java/testng/
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/test/java/testng/BasicTest.java
(with props)
Modified:
maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternBeforeIT.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternBeforeIT.java?rev=1088960&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternBeforeIT.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternBeforeIT.java
Tue Apr 5 10:40:34 2011
@@ -0,0 +1,35 @@
+package org.apache.maven.surefire.its;
+/*
+ * 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.
+ */
+
+
+/**
+ * Test project using -Dtest=mtClass#myMethod*
+ *
+ * @author <a href="mailto:[email protected]">Olivier Lamy</a>
+ */
+public class TestNgTestMethodPatternBeforeIT
+ extends AsbtractTestMethodPattern
+{
+ public TestNgTestMethodPatternBeforeIT()
+ {
+ super( "/testng-method-pattern-before" );
+ }
+
+}
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternBeforeIT.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternBeforeIT.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternBeforeIT.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml?rev=1088960&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml
Tue Apr 5 10:40:34 2011
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>junit4</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>Test for Testng</name>
+
+
+ <properties>
+ <testNgVersion>5.7</testNgVersion>
+ <testNgClassifier>jdk15</testNgClassifier>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>testng-old</id>
+ <activation>
+ <property><name>testNgClassifier</name></property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>${testNgVersion}</version>
+ <classifier>${testNgClassifier}</classifier>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>testng-new</id>
+ <activation>
+ <property><name>!testNgClassifier</name></property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>${testNgVersion}</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ <configuration>
+ <test>BasicTest#testSuccess*</test>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/test/java/testng/BasicTest.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/test/java/testng/BasicTest.java?rev=1088960&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/test/java/testng/BasicTest.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/test/java/testng/BasicTest.java
Tue Apr 5 10:40:34 2011
@@ -0,0 +1,59 @@
+package testng;
+import org.testng.annotations.*;
+import org.testng.Assert;
+
+public class BasicTest
+{
+
+ private boolean setUpCalled = false;
+
+ private static boolean tearDownCalled = false;
+
+ private Integer foo;
+
+ @BeforeTest
+ public void intialize()
+ {
+ setUpCalled = true;
+ tearDownCalled = false;
+ System.out.println( "Called setUp" );
+ foo = Integer.valueOf( 1 );
+ }
+
+ @AfterTest
+ public void shutdown()
+ {
+ setUpCalled = false;
+ tearDownCalled = true;
+ System.out.println( "Called tearDown" );
+ }
+
+ @Test
+ public void testSetUp()
+ {
+ Assert.assertTrue( setUpCalled );
+ Assert.assertNotNull( foo );
+ }
+
+
+ @Test
+ public void testSuccessOne()
+ {
+ Assert.assertTrue( true );
+ Assert.assertNotNull( foo );
+ }
+
+ @Test
+ public void testSuccessTwo()
+ {
+ Assert.assertTrue( true );
+ Assert.assertNotNull( foo );
+ }
+
+ @AfterClass
+ public static void oneTimeTearDown()
+ {
+
+ }
+
+}
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/test/java/testng/BasicTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/test/java/testng/BasicTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/testng-method-pattern-before/src/test/java/testng/BasicTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified:
maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java?rev=1088960&r1=1088959&r2=1088960&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java
(original)
+++
maven/surefire/trunk/surefire-providers/surefire-testng-utils/src/main/java/org/apache/maven/surefire/testng/utils/MethodSelector.java
Tue Apr 5 10:40:34 2011
@@ -19,36 +19,51 @@ package org.apache.maven.surefire.testng
* under the License.
*/
-import java.util.List;
-
import org.codehaus.plexus.util.SelectorUtils;
import org.testng.IMethodSelector;
import org.testng.IMethodSelectorContext;
import org.testng.ITestNGMethod;
+import java.util.List;
+
/**
* For internal use only
- * @author Olivier Lamy
- * @since 2.7.3
*
+ * @author Olivier Lamy
* @noinspection UnusedDeclaration
+ * @since 2.7.3
*/
-public class MethodSelector implements IMethodSelector
+public class MethodSelector
+ implements IMethodSelector
{
-
+
private static String METHOD_NAME = null;
-
+
public void setTestMethods( List arg0 )
{
// noop
}
-
+
public boolean includeMethod( IMethodSelectorContext context,
ITestNGMethod testngMethod, boolean isTestMethod )
{
+
+ if ( testngMethod.isBeforeClassConfiguration() ||
testngMethod.isBeforeGroupsConfiguration()
+ || testngMethod.isBeforeMethodConfiguration() ||
testngMethod.isBeforeSuiteConfiguration()
+ || testngMethod.isBeforeTestConfiguration() )
+ {
+ return true;
+ }
+ if ( testngMethod.isAfterClassConfiguration() ||
testngMethod.isAfterGroupsConfiguration()
+ || testngMethod.isAfterMethodConfiguration() ||
testngMethod.isAfterSuiteConfiguration()
+ || testngMethod.isAfterTestConfiguration() )
+ {
+ return true;
+ }
+
return SelectorUtils.match( METHOD_NAME, testngMethod.getMethodName()
);
}
-
- public static void setMethodName(String methodName)
+
+ public static void setMethodName( String methodName )
{
METHOD_NAME = methodName;
}