Class ExceptionVerifier<T extends RuntimeException>

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public class ExceptionVerifier<T extends RuntimeException>
    extends Object
    implements org.junit.rules.TestRule
    A rule to access an exception from a test using a Consumer Usage example :
     
     Rule public ExceptionVerifier<HttpException> httpExceptionRule = new ExceptionVerifier<>();
      &#64;Test
      public void test(){
          httpExceptionRule.assertWith(e -> {
              assertEquals(401, e.getResponse().status());
              assertEquals("expected error message", e.getResponse().error(String.class));
          });
      }
     
     
    • Method Detail

      • apply

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