Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@listeners was not working with hookable and configurable.
- Loading branch information
Showing
10 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package test.hook; | ||
|
||
import org.testng.IConfigurable; | ||
import org.testng.IConfigureCallBack; | ||
import org.testng.ITestResult; | ||
|
||
public class ConfigurableListener implements IConfigurable { | ||
public static int m_hookCount = 0; | ||
|
||
@Override | ||
public void run(IConfigureCallBack callBack, ITestResult testResult) { | ||
m_hookCount++; | ||
callBack.runConfigurationMethod(testResult); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/test/java/test/hook/ConfigurableSuccessWithListenerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package test.hook; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Listeners; | ||
import org.testng.annotations.Test; | ||
|
||
@Listeners(ConfigurableListener.class) | ||
public class ConfigurableSuccessWithListenerTest { | ||
protected boolean m_bm = false; | ||
protected boolean m_bc = false; | ||
|
||
@BeforeMethod | ||
public void bm() { | ||
m_bm = true; | ||
} | ||
|
||
@BeforeClass | ||
public void bc() { | ||
m_bc = true; | ||
} | ||
|
||
@Test | ||
public void hookWasRun() { | ||
Assert.assertEquals(ConfigurableListener.m_hookCount, 2); | ||
Assert.assertTrue(m_bc); | ||
Assert.assertTrue(m_bm); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package test.hook; | ||
|
||
import org.testng.IHookCallBack; | ||
import org.testng.IHookable; | ||
import org.testng.ITestResult; | ||
|
||
public class HookListener implements IHookable { | ||
public static boolean m_hook = false; | ||
|
||
@Override | ||
public void run(IHookCallBack callBack, ITestResult testResult) { | ||
m_hook = true; | ||
callBack.runTestMethod(testResult); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package test.hook; | ||
|
||
import org.testng.Assert; | ||
import org.testng.annotations.Listeners; | ||
import org.testng.annotations.Test; | ||
|
||
@Listeners(HookListener.class) | ||
public class HookSuccessWithListenerTest { | ||
|
||
@Test | ||
public void verify() { | ||
Assert.assertTrue(HookListener.m_hook); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters