Class TestFailureAwareRule

  • All Implemented Interfaces:
    org.junit.rules.TestRule
    Direct Known Subclasses:
    AbstractSeleniumProvider, JavascriptAlert, LogContext, PageSource, ResourceHelper, ScreenshotRule, WebDriverLog

    @Deprecated
    public class TestFailureAwareRule
    extends java.lang.Object
    implements org.junit.rules.TestRule
    Deprecated.
    Similar to ExternalResource, but gives possibility to do something in case of errors. Also if there is a test error, this class takes care, that errors from its implementations are added as suppressed exceptions to the test error to avoid loosing that original problem. If the test was successful, but after(Description, Throwable) throws an error, then the test will fail.
    • Constructor Summary

      Constructors 
      Constructor Description
      TestFailureAwareRule()
      Deprecated.
      Just to make sure, that this class will not be instantiated, only its children
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected void after​(org.junit.runner.Description description, java.lang.Throwable testFailure)
      Deprecated.
      Called after all tests always.
      org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement base, org.junit.runner.Description description)
      Deprecated.
       
      protected void before​(org.junit.runner.Description description)
      Deprecated.
      Can do something before a test.
      protected void onError​(org.junit.runner.Description description, java.lang.Throwable testFailure)
      Deprecated.
      Called if the test has thrown an error.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TestFailureAwareRule

        public TestFailureAwareRule()
        Deprecated.
        Just to make sure, that this class will not be instantiated, only its children
    • Method Detail

      • before

        protected void before​(org.junit.runner.Description description)
                       throws java.lang.Throwable
        Deprecated.
        Can do something before a test. By default it does nothing.
        Parameters:
        description - junit test description object
        Throws:
        java.lang.Throwable - any error from the test
      • after

        protected void after​(org.junit.runner.Description description,
                             java.lang.Throwable testFailure)
                      throws java.lang.Throwable
        Deprecated.
        Called after all tests always. By default it does nothing.
        Parameters:
        description - junit test description object
        testFailure - in case of failed test it contains an exception. Otherwise null
        Throws:
        java.lang.Throwable - if testFailure is null, it will fly, if testFailure is not null, it will be added to that as suppressed exception. See Throwable.addSuppressed(Throwable)
      • onError

        protected void onError​(org.junit.runner.Description description,
                               java.lang.Throwable testFailure)
                        throws java.lang.Throwable
        Deprecated.
        Called if the test has thrown an error. By default it does nothing.
        Parameters:
        description - junit test description object
        testFailure - any error from the test
        Throws:
        java.lang.Throwable - this will be added to testFailure as suppressed exception. See Throwable.addSuppressed(Throwable)
      • apply

        public org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement base,
                                                       org.junit.runner.Description description)
        Deprecated.
        Specified by:
        apply in interface org.junit.rules.TestRule