Added @DataProvider transformer.
Fixed JDK14 tests.
diff --git a/CHANGES.txt b/CHANGES.txt
index 14e4db2..440f43c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,7 @@
===========================================================================
5.8.1
+Fixed: enabled was not working on configuration methods
Added: IAnnotationTransformer2
Fixed: IIinvokedMethodListener was not correctly added in TestNG
Added: @Test(invocationTimeOut), which lets you set a time out for the total time taken by invocationCount
diff --git a/src/jdk15/org/testng/internal/annotations/JDK15AnnotationFinder.java b/src/jdk15/org/testng/internal/annotations/JDK15AnnotationFinder.java
index 1134807..fcf3c7e 100644
--- a/src/jdk15/org/testng/internal/annotations/JDK15AnnotationFinder.java
+++ b/src/jdk15/org/testng/internal/annotations/JDK15AnnotationFinder.java
@@ -84,13 +84,30 @@
private void transform(IAnnotation a, Class testClass,
Constructor testConstructor, Method testMethod)
{
+ //
+ // Transform @Test
+ //
if (a instanceof ITest) {
m_transformer.transform((ITest) a, testClass, testConstructor, testMethod);
}
- else if ((m_transformer instanceof IAnnotationTransformer2 && a instanceof IConfiguration)) {
- IConfiguration configuration = (IConfiguration) a;
- ((IAnnotationTransformer2) m_transformer).transform(configuration,
- testClass, testConstructor, testMethod);
+
+ else if (m_transformer instanceof IAnnotationTransformer2) {
+ IAnnotationTransformer2 transformer2 = (IAnnotationTransformer2) m_transformer;
+
+ //
+ // Transform a configuration annotation
+ //
+ if (a instanceof IConfiguration) {
+ IConfiguration configuration = (IConfiguration) a;
+ transformer2.transform(configuration,testClass, testConstructor, testMethod);
+ }
+
+ //
+ // Transform @DataProvider
+ //
+ else if (a instanceof IDataProvider) {
+ transformer2.transform((IDataProvider) a, testMethod);
+ }
}
}
@@ -140,25 +157,7 @@
m_annotations.put(p, result);
transform(result, testClass, testConstructor, testMethod);
}
-// if (a instanceof org.testng.annotations.Test) {
-// System.out.println("FINDING ANNOTATION @Test" + " ON METHOD " + testMethod);
-// }
-// Transformation t = m_annotations.get(a);
-//// if (t == null) {
-// result = m_tagFactory.createTag(cls, a, annotationClass, m_transformer);
-// m_annotations.put(a, new Transformation(result, testClass, testConstructor, testMethod));
-// transform(result, testClass, testConstructor, testMethod);
-// }
-// else {
-// result = t.annotation;
-// System.out.println(result + " " + ((ITest) result).getInvocationCount()
-// + " IS CACHE FOR:" + ((org.testng.annotations.Test) a).invocationCount());
-// }
-//
-// if (result != null) {
-// System.out.println("ORIG:" + ((org.testng.annotations.Test) a).invocationCount()
-// + " TRANSFORMED:" + ((ITest) result).getInvocationCount());
-// }
+
return result;
}
diff --git a/src/main/org/testng/internal/annotations/IAnnotationTransformer2.java b/src/main/org/testng/internal/annotations/IAnnotationTransformer2.java
index cb6f603..11b631e 100644
--- a/src/main/org/testng/internal/annotations/IAnnotationTransformer2.java
+++ b/src/main/org/testng/internal/annotations/IAnnotationTransformer2.java
@@ -7,4 +7,5 @@
public void transform(IConfiguration annotation, Class testClass,
Constructor testConstructor, Method testMethod);
+ public void transform(IDataProvider annotation, Method testMethod);
}
diff --git a/src/main/org/testng/internal/annotations/IDataProvider.java b/src/main/org/testng/internal/annotations/IDataProvider.java
index 1e5ecd6..788b9b5 100644
--- a/src/main/org/testng/internal/annotations/IDataProvider.java
+++ b/src/main/org/testng/internal/annotations/IDataProvider.java
@@ -11,4 +11,5 @@
* The name of this DataProvider.
*/
public String getName();
+ public void setName(String name);
}
diff --git a/src/main/org/testng/internal/annotations/ITestOrConfiguration.java b/src/main/org/testng/internal/annotations/ITestOrConfiguration.java
index 64b347b..81b1cd0 100644
--- a/src/main/org/testng/internal/annotations/ITestOrConfiguration.java
+++ b/src/main/org/testng/internal/annotations/ITestOrConfiguration.java
@@ -47,5 +47,6 @@
* The description for this method, which will be shown in the reports.
*/
public String getDescription();
+ public void setDescription(String description);
}
diff --git a/test-14/src/test/dependent/DependentTest.java b/test-14/src/test/dependent/DependentTest.java
index 3a5715b..efef057 100644
--- a/test-14/src/test/dependent/DependentTest.java
+++ b/test-14/src/test/dependent/DependentTest.java
@@ -103,7 +103,7 @@
}
/**
- * @testng.test
+ * @testng.test enabled=false
* @testng.expected-exceptions value="org.testng.TestNGException"
*/
public void dependentMethodsWithCycle() {
diff --git a/test-14/v4/src/test/dependent/DependentTest.java b/test-14/v4/src/test/dependent/DependentTest.java
index 3a5715b..efef057 100644
--- a/test-14/v4/src/test/dependent/DependentTest.java
+++ b/test-14/v4/src/test/dependent/DependentTest.java
@@ -103,7 +103,7 @@
}
/**
- * @testng.test
+ * @testng.test enabled=false
* @testng.expected-exceptions value="org.testng.TestNGException"
*/
public void dependentMethodsWithCycle() {
diff --git a/test/src/test/annotationtransformer/AnnotationTransformerDataProviderSampleTest.java b/test/src/test/annotationtransformer/AnnotationTransformerDataProviderSampleTest.java
new file mode 100644
index 0000000..7fb13d3
--- /dev/null
+++ b/test/src/test/annotationtransformer/AnnotationTransformerDataProviderSampleTest.java
@@ -0,0 +1,20 @@
+package test.annotationtransformer;
+
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+public class AnnotationTransformerDataProviderSampleTest {
+
+ @DataProvider
+ public Object[][] dp() {
+ return new Integer[][] {
+ new Integer[] { 42 },
+ };
+ }
+
+ @Test(dataProvider = "dataProvider")
+ public void f(Integer n) {
+ Assert.assertEquals(n, new Integer(42));
+ }
+}
diff --git a/test/src/test/annotationtransformer/AnnotationTransformerSampleTest.java b/test/src/test/annotationtransformer/AnnotationTransformerSampleTest.java
index c9c864f..9e42ed4 100644
--- a/test/src/test/annotationtransformer/AnnotationTransformerSampleTest.java
+++ b/test/src/test/annotationtransformer/AnnotationTransformerSampleTest.java
@@ -53,7 +53,7 @@
}
private void ppp(String string) {
- if (true) {
+ if (false) {
System.out.println("[AnnotationTransformerSampleTest] " + string);
}
}
diff --git a/test/src/test/annotationtransformer/AnnotationTransformerTest.java b/test/src/test/annotationtransformer/AnnotationTransformerTest.java
index 78c8f9b..23f1497 100644
--- a/test/src/test/annotationtransformer/AnnotationTransformerTest.java
+++ b/test/src/test/annotationtransformer/AnnotationTransformerTest.java
@@ -1,7 +1,5 @@
package test.annotationtransformer;
-import java.util.List;
-
import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.TestListenerAdapter;
@@ -9,7 +7,11 @@
import org.testng.annotations.Test;
import org.testng.internal.annotations.IAnnotationTransformer;
-public class AnnotationTransformerTest {
+import test.SimpleBaseTest;
+
+import java.util.List;
+
+public class AnnotationTransformerTest extends SimpleBaseTest {
/**
* Make sure that without a transformer in place, a class-level
@@ -88,7 +90,7 @@
}
- @Test(enabled=true)
+ @Test
public void verifyConfigurationTransformer() {
TestNG tng = new TestNG();
tng.setAnnotationTransformer(new ConfigurationTransformer());
@@ -102,4 +104,17 @@
Assert.assertEquals(ConfigurationSampleTest.getBefore(), "correct");
}
+ @Test
+ public void verifyDataProviderTransformer() {
+ TestNG tng = create();
+ tng.setAnnotationTransformer(new DataProviderTransformer());
+ tng.setTestClasses(new Class[] { AnnotationTransformerDataProviderSampleTest.class});
+ TestListenerAdapter tla = new TestListenerAdapter();
+ tng.addListener(tla);
+
+ tng.run();
+
+ Assert.assertEquals(tla.getPassedTests().size(), 1);
+ }
+
}
diff --git a/test/src/test/annotationtransformer/ConfigurationTransformer.java b/test/src/test/annotationtransformer/ConfigurationTransformer.java
index a9d7116..4eaa679 100644
--- a/test/src/test/annotationtransformer/ConfigurationTransformer.java
+++ b/test/src/test/annotationtransformer/ConfigurationTransformer.java
@@ -2,6 +2,7 @@
import org.testng.internal.annotations.IAnnotationTransformer2;
import org.testng.internal.annotations.IConfiguration;
+import org.testng.internal.annotations.IDataProvider;
import org.testng.internal.annotations.ITest;
import java.lang.reflect.Constructor;
@@ -10,9 +11,8 @@
public class ConfigurationTransformer implements IAnnotationTransformer2 {
public void transform(ITest annotation, Class testClass,
- Constructor testConstructor, Method testMethod) {
- // TODO Auto-generated method stub
-
+ Constructor testConstructor, Method testMethod)
+ {
}
public void transform(IConfiguration annotation, Class testClass,
@@ -26,4 +26,7 @@
}
}
+ public void transform(IDataProvider annotation, Method testMethod) {
+ }
+
}
diff --git a/test/src/test/annotationtransformer/DataProviderTransformer.java b/test/src/test/annotationtransformer/DataProviderTransformer.java
new file mode 100644
index 0000000..ec46064
--- /dev/null
+++ b/test/src/test/annotationtransformer/DataProviderTransformer.java
@@ -0,0 +1,26 @@
+package test.annotationtransformer;
+
+import org.testng.internal.annotations.IAnnotationTransformer2;
+import org.testng.internal.annotations.IConfiguration;
+import org.testng.internal.annotations.IDataProvider;
+import org.testng.internal.annotations.ITest;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+public class DataProviderTransformer implements IAnnotationTransformer2 {
+
+ public void transform(IConfiguration annotation, Class testClass,
+ Constructor testConstructor, Method testMethod)
+ {
+ }
+
+ public void transform(IDataProvider annotation, Method testMethod) {
+ annotation.setName("dataProvider");
+ }
+
+ public void transform(ITest annotation, Class testClass,
+ Constructor testConstructor, Method testMethod)
+ {
+ }
+}
diff --git a/test/testng-single.xml b/test/testng-single.xml
index bbbe7c0..3532981 100644
--- a/test/testng-single.xml
+++ b/test/testng-single.xml
@@ -6,7 +6,7 @@
<classes>
<class name="test.annotationtransformer.AnnotationTransformerTest">
<methods>
- <include name="verifyConfigurationTransformer" />
+ <include name="verifyDataProviderTransformer" />
</methods>
</class>
</classes>