[testng] 211/355: Fix #605
Eugene Zhukov
eugene-guest at moszumanska.debian.org
Tue Aug 18 10:20:06 UTC 2015
This is an automated email from the git hooks/post-receive script.
eugene-guest pushed a commit to annotated tag OpenBSD
in repository testng.
commit c69c22140e946a36987577a0967ea857dc7f40b3
Author: Julien Herr <julien.herr at alcatel-lucent.com>
Date: Thu Apr 23 10:08:36 2015 +0200
Fix #605
---
.../AnnotationTransformerInvocationCountTest.java | 32 ++++++++++++++++++++++
.../AnnotationTransformerTest.java | 22 +++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/src/test/java/test/annotationtransformer/AnnotationTransformerInvocationCountTest.java b/src/test/java/test/annotationtransformer/AnnotationTransformerInvocationCountTest.java
new file mode 100644
index 0000000..9557408
--- /dev/null
+++ b/src/test/java/test/annotationtransformer/AnnotationTransformerInvocationCountTest.java
@@ -0,0 +1,32 @@
+package test.annotationtransformer;
+
+import org.testng.IAnnotationTransformer;
+import org.testng.annotations.ITestAnnotation;
+import org.testng.annotations.Test;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+public class AnnotationTransformerInvocationCountTest {
+
+ public static class InvocationCountTransformer implements IAnnotationTransformer {
+
+ private final int invocationCount;
+
+ public InvocationCountTransformer(int invocationCount) {
+ this.invocationCount = invocationCount;
+ }
+
+ @Override
+ public void transform(ITestAnnotation annotation, Class testClass,
+ Constructor testConstructor, Method testMethod) {
+ if ("concurrencyTest".equals(testMethod.getName())) {
+ annotation.setInvocationCount(invocationCount);
+ }
+ }
+ }
+
+ @Test(invocationCount = 3)
+ public void concurrencyTest() {
+ }
+}
diff --git a/src/test/java/test/annotationtransformer/AnnotationTransformerTest.java b/src/test/java/test/annotationtransformer/AnnotationTransformerTest.java
index 223dd91..16be028 100644
--- a/src/test/java/test/annotationtransformer/AnnotationTransformerTest.java
+++ b/src/test/java/test/annotationtransformer/AnnotationTransformerTest.java
@@ -135,6 +135,28 @@ public class AnnotationTransformerTest extends SimpleBaseTest {
Assert.assertEquals(tla.getPassedTests().size(), 1);
}
+ @Test(description = "Test for issue #605")
+ public void verifyInvocationCountTransformer() {
+ TestNG tng = create();
+ tng.setTestClasses(new Class[] { AnnotationTransformerInvocationCountTest.class });
+ TestListenerAdapter tla = new TestListenerAdapter();
+ tng.addListener(tla);
+
+ tng.run();
+
+ Assert.assertEquals(tla.getPassedTests().size(), 3);
+
+ tng = create();
+ tng.setAnnotationTransformer(new AnnotationTransformerInvocationCountTest.InvocationCountTransformer(5));
+ tng.setTestClasses(new Class[]{AnnotationTransformerInvocationCountTest.class});
+ tla = new TestListenerAdapter();
+ tng.addListener(tla);
+
+ tng.run();
+
+ Assert.assertEquals(tla.getPassedTests().size(), 5);
+ }
+
@Test
public void annotationTransformerInXmlShouldBeRun() throws Exception {
String xml = "<suite name=\"SingleSuite\" >" +
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/testng.git
More information about the pkg-java-commits
mailing list