[testng] 101/160: Add test for #599
Eugene Zhukov
eugene-guest at moszumanska.debian.org
Tue Aug 18 10:22:26 UTC 2015
This is an automated email from the git hooks/post-receive script.
eugene-guest pushed a commit to annotated tag testng-6.9.5
in repository testng.
commit 7b1c6803507dce157c694f30bf8a541eb6df5e48
Author: Julien Herr <julien.herr at alcatel-lucent.com>
Date: Wed Jun 10 01:02:12 2015 +0200
Add test for #599
---
src/test/java/test/hook/HookSuccess599Test.java | 43 +++++++++++++++++++++++++
src/test/java/test/hook/HookableTest.java | 14 ++++++++
2 files changed, 57 insertions(+)
diff --git a/src/test/java/test/hook/HookSuccess599Test.java b/src/test/java/test/hook/HookSuccess599Test.java
new file mode 100644
index 0000000..307c23f
--- /dev/null
+++ b/src/test/java/test/hook/HookSuccess599Test.java
@@ -0,0 +1,43 @@
+package test.hook;
+
+import org.testng.IHookCallBack;
+import org.testng.IHookable;
+import org.testng.ITestResult;
+import org.testng.Reporter;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Test harness for {@link IHookable}
+ *
+ * @author <a href="mailto:cedric at beust.com">Cedric Beust</a>
+ * @since Aug 01, 2006
+ */
+public class HookSuccess599Test implements IHookable {
+ static boolean m_hook = false;
+ static boolean m_testWasRun = false;
+ static String m_parameter = null;
+
+ @Override
+ public void run(IHookCallBack callBack, ITestResult testResult) {
+ m_hook = true;
+ Object[] parameters = callBack.getParameters();
+ if (parameters.length > 0) {
+ m_parameter = parameters[0].toString();
+ }
+ callBack.runTestMethod(testResult);
+ }
+
+ @DataProvider
+ public Object[][] dp() {
+ return new Object[][] {
+ new Object[] { "foo" }
+ };
+ }
+
+ @Test(dataProvider = "dp", timeOut = 100)
+ public void verify(String name) {
+ m_testWasRun = true;
+ Reporter.log("output from hook test.verify");
+ }
+}
diff --git a/src/test/java/test/hook/HookableTest.java b/src/test/java/test/hook/HookableTest.java
index 672a549..a01e81c 100644
--- a/src/test/java/test/hook/HookableTest.java
+++ b/src/test/java/test/hook/HookableTest.java
@@ -19,6 +19,9 @@ public class HookableTest extends BaseTest {
HookSuccessTest.m_hook = false;
HookSuccessTest.m_testWasRun = false;
HookSuccessTest.m_parameter = null;
+ HookSuccess599Test.m_hook = false;
+ HookSuccess599Test.m_testWasRun = false;
+ HookSuccess599Test.m_parameter = null;
HookFailureTest.m_hook = false;
HookFailureTest.m_testWasRun = false;
HookListener.m_hook = false;
@@ -45,6 +48,17 @@ public class HookableTest extends BaseTest {
Assert.assertEquals(HookSuccessTest.m_parameter, "foo");
}
+ @Test(description = "https://github.com/cbeust/testng/issues/599")
+ public void issue599() {
+ addClass(HookSuccess599Test.class);
+ run();
+
+ verifyTests("Passed", new String[] { "verify" }, getPassedTests());
+ Assert.assertTrue(HookSuccess599Test.m_hook);
+ Assert.assertTrue(HookSuccess599Test.m_testWasRun);
+ Assert.assertEquals(HookSuccess599Test.m_parameter, "foo");
+ }
+
@Test
public void hookSuccessWithListener() {
addClass(HookSuccessWithListenerTest.class);
--
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