Class Verifier

  • All Implemented Interfaces:
    TestRule
    Direct Known Subclasses:
    ErrorCollector

    public abstract class Verifier
    extends java.lang.Object
    implements TestRule
    Verifier is a base class for Rules like ErrorCollector, which can turn otherwise passing test methods into failing tests if a verification check is failed
         public static class ErrorLogVerifier {
            private ErrorLog errorLog = new ErrorLog();
    
            @Rule
            public Verifier verifier = new Verifier() {
               @Override public void verify() {
                  assertTrue(errorLog.isEmpty());
               }
            }
    
            @Test public void testThatMightWriteErrorLog() {
               // ...
            }
         }
     
    Since:
    4.7
    • Constructor Summary

      Constructors 
      Constructor Description
      Verifier()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Statement apply​(Statement base, Description description)
      Modifies the method-running Statement to implement this test-running rule.
      protected void verify()
      Override this to add verification logic.
      • Methods inherited from class java.lang.Object

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

      • apply

        public Statement apply​(Statement base,
                               Description description)
        Description copied from interface: TestRule
        Modifies the method-running Statement to implement this test-running rule.
        Specified by:
        apply in interface TestRule
        Parameters:
        base - The Statement to be modified
        description - A Description of the test implemented in base
        Returns:
        a new statement, which may be the same as base, a wrapper around base, or a completely new Statement.
      • verify

        protected void verify()
                       throws java.lang.Throwable
        Override this to add verification logic. Overrides should throw an exception to indicate that verification failed.
        Throws:
        java.lang.Throwable