程序包 org.junit.rules

类 Verifier

  • 所有已实现的接口:
    TestRule
    直接已知子类:
    ErrorCollector

    public abstract class Verifier
    extends 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() {
               // ...
            }
         }
     
    从以下版本开始:
    4.7
    • 构造器详细资料

    • 方法详细资料

      • apply

        public Statement apply​(Statement base,
                               Description description)
        从接口复制的说明: TestRule
        Modifies the method-running Statement to implement this test-running rule.
        指定者:
        apply 在接口中 TestRule
        参数:
        base - The Statement to be modified
        description - A Description of the test implemented in base
        返回:
        a new statement, which may be the same as base, a wrapper around base, or a completely new Statement.
      • verify

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