[testng] 243/355: Add test for @Test(enable) feature
Eugene Zhukov
eugene-guest at moszumanska.debian.org
Tue Aug 18 10:20:10 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 d1a9f5469757c23dcf11d931585f57575cd73249
Author: Julien Herr <julien.herr at alcatel-lucent.com>
Date: Thu Apr 30 13:42:49 2015 +0200
Add test for @Test(enable) feature
---
src/test/java/test/enable/A.java | 45 +++++++++++++++++++++
src/test/java/test/enable/B.java | 46 ++++++++++++++++++++++
src/test/java/test/enable/C.java | 46 ++++++++++++++++++++++
src/test/java/test/enable/EnableTest.java | 44 +++++++++++++++++++++
.../java/test/enable/InvokedMethodListener.java | 27 +++++++++++++
5 files changed, 208 insertions(+)
diff --git a/src/test/java/test/enable/A.java b/src/test/java/test/enable/A.java
new file mode 100644
index 0000000..45bd922
--- /dev/null
+++ b/src/test/java/test/enable/A.java
@@ -0,0 +1,45 @@
+package test.enable;
+
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+public class A {
+
+ public void testA() {}
+
+ @Test
+ public void testA2() {}
+
+ @Test(enabled = true)
+ public void testA3() {}
+
+ @Test(enabled = false)
+ public void disabledA() {}
+
+ @BeforeSuite
+ public void beforeSuiteA() {}
+
+ @BeforeSuite(enabled = true)
+ public void beforeSuiteA2() {}
+
+ @BeforeSuite(enabled = false)
+ public void disabledBeforeSuiteA() {}
+
+ @BeforeSuite(alwaysRun = false)
+ public void beforeSuiteNoRunA() {}
+
+ @BeforeSuite(enabled = true, alwaysRun = false)
+ public void beforeSuiteNoRunA2() {}
+
+ @BeforeSuite(enabled = false, alwaysRun = false)
+ public void disabledBeforeSuiteNoRunA() {}
+
+ @BeforeSuite(alwaysRun = true)
+ public void beforeSuiteRunA() {}
+
+ @BeforeSuite(enabled = true, alwaysRun = true)
+ public void beforeSuiteRunA2() {}
+
+ @BeforeSuite(enabled = false, alwaysRun = true)
+ public void disabledBeforeSuiteRunA() {}
+}
diff --git a/src/test/java/test/enable/B.java b/src/test/java/test/enable/B.java
new file mode 100644
index 0000000..c486438
--- /dev/null
+++ b/src/test/java/test/enable/B.java
@@ -0,0 +1,46 @@
+package test.enable;
+
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+ at Test(enabled = false)
+public class B {
+
+ public void testB() {}
+
+ @Test
+ public void testB2() {}
+
+ @Test(enabled = true)
+ public void testB3() {}
+
+ @Test(enabled = false)
+ public void disabledB() {}
+
+ @BeforeSuite(enabled = true)
+ public void disabledBeforeSuiteB() {}
+
+ @BeforeSuite
+ public void disabledBeforeSuiteB2() {}
+
+ @BeforeSuite(enabled = false)
+ public void disabledBeforeSuiteB3() {}
+
+ @BeforeSuite(alwaysRun = false)
+ public void beforeSuiteNoRunB() {}
+
+ @BeforeSuite(enabled = true, alwaysRun = false)
+ public void beforeSuiteNoRunB2() {}
+
+ @BeforeSuite(enabled = false, alwaysRun = false)
+ public void disabledBeforeSuiteNoRunB() {}
+
+ @BeforeSuite(alwaysRun = true)
+ public void beforeSuiteRunB() {}
+
+ @BeforeSuite(enabled = true, alwaysRun = true)
+ public void beforeSuiteRunB2() {}
+
+ @BeforeSuite(enabled = false, alwaysRun = true)
+ public void disabledBeforeSuiteRunB() {}
+}
diff --git a/src/test/java/test/enable/C.java b/src/test/java/test/enable/C.java
new file mode 100644
index 0000000..7794036
--- /dev/null
+++ b/src/test/java/test/enable/C.java
@@ -0,0 +1,46 @@
+package test.enable;
+
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+ at Test
+public class C {
+
+ public void testC() {}
+
+ @Test
+ public void testC2() {}
+
+ @Test(enabled = true)
+ public void testC3() {}
+
+ @Test(enabled = false)
+ public void disabledC() {}
+
+ @BeforeSuite
+ public void beforeSuiteC() {}
+
+ @BeforeSuite(enabled = true)
+ public void beforeSuiteC2() {}
+
+ @BeforeSuite(enabled = false)
+ public void disabledBeforeSuiteC() {}
+
+ @BeforeSuite(alwaysRun = false)
+ public void beforeSuiteNoRunC() {}
+
+ @BeforeSuite(enabled = true, alwaysRun = false)
+ public void beforeSuiteNoRunC2() {}
+
+ @BeforeSuite(enabled = false, alwaysRun = false)
+ public void disabledBeforeSuiteNoRunC() {}
+
+ @BeforeSuite(alwaysRun = true)
+ public void beforeSuiteRunC() {}
+
+ @BeforeSuite(enabled = true, alwaysRun = true)
+ public void beforeSuiteRunC2() {}
+
+ @BeforeSuite(enabled = false, alwaysRun = true)
+ public void disabledBeforeSuiteRunC() {}
+}
diff --git a/src/test/java/test/enable/EnableTest.java b/src/test/java/test/enable/EnableTest.java
new file mode 100644
index 0000000..510288b
--- /dev/null
+++ b/src/test/java/test/enable/EnableTest.java
@@ -0,0 +1,44 @@
+package test.enable;
+
+import org.testng.Assert;
+import org.testng.IInvokedMethod;
+import org.testng.TestNG;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+import test.SimpleBaseTest;
+
+public class EnableTest extends SimpleBaseTest {
+
+ @Test
+ public void disabled_methods_should_not_be_run() {
+ TestNG tng = create(A.class, B.class, C.class);
+ InvokedMethodListener listener = new InvokedMethodListener();
+ tng.addListener(listener);
+ tng.setPreserveOrder(true);
+ tng.run();
+
+ List<String> invokedMethods = listener.getInvokedMethods();
+ Assert.assertEquals(invokedMethods.get(0), "beforeSuiteA");
+ Assert.assertEquals(invokedMethods.get(1), "beforeSuiteA2");
+ Assert.assertEquals(invokedMethods.get(2), "beforeSuiteNoRunA");
+ Assert.assertEquals(invokedMethods.get(3), "beforeSuiteNoRunA2");
+ Assert.assertEquals(invokedMethods.get(4), "beforeSuiteRunA");
+ Assert.assertEquals(invokedMethods.get(5), "beforeSuiteRunA2");
+ Assert.assertEquals(invokedMethods.get(6), "beforeSuiteC");
+ Assert.assertEquals(invokedMethods.get(7), "beforeSuiteC2");
+ Assert.assertEquals(invokedMethods.get(8), "beforeSuiteNoRunC");
+ Assert.assertEquals(invokedMethods.get(9), "beforeSuiteNoRunC2");
+ Assert.assertEquals(invokedMethods.get(10), "beforeSuiteRunC");
+ Assert.assertEquals(invokedMethods.get(11), "beforeSuiteRunC2");
+ Assert.assertEquals(invokedMethods.get(12), "testA2");
+ Assert.assertEquals(invokedMethods.get(13), "testA3");
+ Assert.assertEquals(invokedMethods.get(14), "testB2");
+ Assert.assertEquals(invokedMethods.get(15), "testB3");
+ Assert.assertEquals(invokedMethods.get(16), "testC");
+ Assert.assertEquals(invokedMethods.get(17), "testC2");
+ Assert.assertEquals(invokedMethods.get(18), "testC3");
+ Assert.assertEquals(invokedMethods.size(), 19);
+ }
+}
diff --git a/src/test/java/test/enable/InvokedMethodListener.java b/src/test/java/test/enable/InvokedMethodListener.java
new file mode 100644
index 0000000..35b68a2
--- /dev/null
+++ b/src/test/java/test/enable/InvokedMethodListener.java
@@ -0,0 +1,27 @@
+package test.enable;
+
+import org.testng.IInvokedMethod;
+import org.testng.IInvokedMethodListener;
+import org.testng.ITestResult;
+import org.testng.collections.Lists;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class InvokedMethodListener implements IInvokedMethodListener {
+
+ private final List<String> invokedMethods = new ArrayList<>();
+
+ @Override
+ public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
+ invokedMethods.add(method.getTestMethod().getMethodName());
+ }
+
+ @Override
+ public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
+ }
+
+ public List<String> getInvokedMethods() {
+ return invokedMethods;
+ }
+}
--
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