public class

Verifier

extends Object
implements MethodRule
java.lang.Object
   ↳ org.junit.rules.Verifier
Known Direct Subclasses

Class Overview

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 MethodRule verifier = new Verifier() {
           @Override public void verify() {
              assertTrue(errorLog.isEmpty());
           }
        }
        
        @Test public void testThatMightWriteErrorLog() {
           // ...
        }
     }
 

Summary

Public Constructors
Verifier()
Public Methods
Statement apply(Statement base, FrameworkMethod method, Object target)
Modifies the method-running Statement to implement an additional test-running rule.
Protected Methods
void verify()
Override this to add verification logic.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.junit.rules.MethodRule

Public Constructors

public Verifier ()

Public Methods

public Statement apply (Statement base, FrameworkMethod method, Object target)

Modifies the method-running Statement to implement an additional test-running rule.

Parameters
base The Statement to be modified
method The method to be run
target The object on with the method will be run.
Returns
  • a new statement, which may be the same as base, a wrapper around base, or a completely new Statement.

Protected Methods

protected void verify ()

Override this to add verification logic. Overrides should throw an exception to indicate that verification failed.

Throws
Throwable