Package org.junit

Examples of org.junit.Test.expected()


        if (testAnnotation != null) {
          for (Method setup : setups) {
            setup.invoke(instance, (Object[]) null);
          }

          Class expectedException = testAnnotation.expected();

          // can't for the life of me get eclipse to be able to
          // resolve Test.None directly
          if (expectedException.getName().equals(
              "org.junit.Test$None")) // why the hell doesn't this
View Full Code Here


              new BufferedReader(new InputStreamReader(System.in))
                  .readLine();
            } else {
              // is there a cleaner way of saying this?
              if (!e.getCause().getClass().equals(
                  testAnnotation.expected())) {
                System.out.println(testClass.getName() + "."
                    + method.getName() + ": "
                    + "Exception expected: "
                    + testAnnotation.expected().getName()
                    + ", Exception thrown: "
View Full Code Here

              if (!e.getCause().getClass().equals(
                  testAnnotation.expected())) {
                System.out.println(testClass.getName() + "."
                    + method.getName() + ": "
                    + "Exception expected: "
                    + testAnnotation.expected().getName()
                    + ", Exception thrown: "
                    + e.getCause().getMessage());
                new BufferedReader(new InputStreamReader(
                    System.in)).readLine();
              }
View Full Code Here

          if (expectedException != null) {
            System.out.println(testClass.getName() + "."
                + method.getName() + ": "
                + "Expected exception not thrown: "
                + testAnnotation.expected().getName());
            new BufferedReader(new InputStreamReader(System.in))
                .readLine();
          }

          for (Method tearDown : tearDowns) {
View Full Code Here

    }

    @Override
    protected Statement possiblyExpectingExceptions(FrameworkMethod method, Object test, Statement next) {
        Test annotation = method.getAnnotation(Test.class);
        Class<? extends Throwable> expected = annotation.expected();
        if (expected != Test.None.class) {
            expectedException = expected;
            if (workflowTestRule != null) {
                workflowTestRule.setExpectedException(expectedException);
            }
View Full Code Here

    }

    @Override
    protected Statement possiblyExpectingExceptions(FrameworkMethod method, Object test, Statement next) {
        Test annotation = method.getAnnotation(Test.class);
        Class<? extends Throwable> expected = annotation.expected();
        if (expected != Test.None.class) {
            expectedException = expected;
            if (workflowTestRule != null) {
                workflowTestRule.setExpectedException(expectedException);
            }
View Full Code Here

  }

  @SuppressWarnings("all")
  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

  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

      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

     
      // 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

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.