Class AfterTestHook

  • All Implemented Interfaces:
    org.testng.IHookable, org.testng.ITestNGListener
    Direct Known Subclasses:
    BaseTestCase

    public class AfterTestHook
    extends MockSupport
    implements org.testng.IHookable
    TestNG hook allowing to perform custom verification after each test (for example, ensure that there were no errors in TestLogger). We shouldn't do it using AfterMethod method because it results in that TestNG skips all the following tests.
    Author:
    Dmitry Treskunov
    • Constructor Detail

      • AfterTestHook

        public AfterTestHook()
    • Method Detail

      • initializeAfterTestHook

        @BeforeMethod(alwaysRun=true)
        protected void initializeAfterTestHook()
                                        throws Exception
        Throws:
        Exception
      • run

        public void run​(org.testng.IHookCallBack callBack,
                        org.testng.ITestResult testResult)
        Specified by:
        run in interface org.testng.IHookable
      • performAfterTestVerification

        protected void performAfterTestVerification()
        You should implement this method if you want to perform any checks after test was run. You shouldn't do it in the AfterMethod because any exception there will result in that TestNG skip all following tests.