Examples of expected()


Examples of org.junit.Test.expected()

  public Class<? extends Throwable> expectedException(Method method) {
    Test annotation = method.getAnnotation(Test.class);
    if (annotation == null || annotation.expected() == None.class)
      return null;
    else
      return annotation.expected();
  }
}
View Full Code Here

Examples of org.junit.Test.expected()

      Statement containerTestRunnerStatement = new ContainerTestRunnerStatement(method, description, context);
     
      // Handle expected exception. We need to handle this explicitly as it is implemented
      // using a statement that we will discard here (as we don't use base)
      Test t = method.getAnnotation(Test.class);
      if (t != null && t.expected() != None.class) {
        testStatement = new ExpectException(containerTestRunnerStatement, t.expected());
      } else {
        testStatement = containerTestRunnerStatement;
      }
    } else {
View Full Code Here

Examples of org.junit.Test.expected()

     
      // Handle expected exception. We need to handle this explicitly as it is implemented
      // using a statement that we will discard here (as we don't use base)
      Test t = method.getAnnotation(Test.class);
      if (t != null && t.expected() != None.class) {
        testStatement = new ExpectException(containerTestRunnerStatement, t.expected());
      } else {
        testStatement = containerTestRunnerStatement;
      }
    } else {
      // With LOCAL_TEST, just run the original statement locally.
View Full Code Here

Examples of org.junit.Test.expected()

    if (ann == null) {
      return s;
    }
   
    // If there's no expected class, don't wrap. Eh, None is package-private...
    final Class<? extends Throwable> expectedClass = ann.expected();
    if (expectedClass.getName().equals("org.junit.Test$None")) {
      return s;
    }

    return new Statement() {
View Full Code Here

Examples of org.junit.Test.expected()

    if (ann == null) {
      return s;
    }
   
    // If there's no expected class, don't wrap. Eh, None is package-private...
    final Class<? extends Throwable> expectedClass = ann.expected();
    if (expectedClass.getName().equals("org.junit.Test$None")) {
      return s;
    }

    return new Statement() {
View Full Code Here

Examples of org.junit.Test.expected()

    if (ann == null) {
      return s;
    }
   
    // If there's no expected class, don't wrap. Eh, None is package-private...
    final Class<? extends Throwable> expectedClass = ann.expected();
    if (expectedClass.getName().equals("org.junit.Test$None")) {
      return s;
    }

    return new Statement() {
View Full Code Here

Examples of org.junit.Test.expected()

   */
  private Statement wrapExpectedExceptions(final Statement s, TestCandidate c, Object instance) {
    Test ann = c.method.getAnnotation(Test.class);

    // If there's no expected class, don't wrap. Eh, None is package-private...
    final Class<? extends Throwable> expectedClass = ann.expected();
    if (expectedClass.getName().equals("org.junit.Test$None")) {
      return s;
    }

    return new Statement() {
View Full Code Here

Examples of org.junit.Test.expected()

      @Override
      public void testFailure(Failure failure) throws Exception {
          exception = State.getTestException();
          Test test = failure.getDescription().getAnnotation(Test.class);
          if ( !(test != null && test.expected() != Test.None.class))
          {
              // Not Expected Exception, and non thrown internally
              if(exception == null) {
                  exception = failure.getException();
              }
View Full Code Here

Examples of org.junit.Test.expected()

      }

      @Override
      public void testFinished(Description description) throws Exception {
          Test test = description.getAnnotation(Test.class);
          if (test != null && test.expected() != Test.None.class)
          {
              if(exception == null) {
                  exception = State.getTestException();
              }
          }
View Full Code Here

Examples of org.junit.Test.expected()

            if (getJunit4()){
                Class<? extends Throwable> expectedException = None.class;
                long timeout = 0;
                Test annotation = m.getAnnotation(Test.class);
                if(null != annotation) {
                    expectedException = annotation.expected();
                    timeout = annotation.timeout();
                }
                final AnnotatedTestCase at = new AnnotatedTestCase(m, expectedException, timeout);
                testCase = at;
                protectable = new Protectable() {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.