Package org.junit

Examples of org.junit.Test


    if (timeoutAnn != null) {
      timeout = timeoutAnn.millis();
    }

    // @Test annotation timeout value.
    Test testAnn = c.method.getAnnotation(Test.class);
    if (testAnn != null && testAnn.timeout() > 0) {
      timeout = (int) Math.min(Integer.MAX_VALUE, testAnn.timeout());
    }

    // Method-override.
    timeoutAnn = c.method.getAnnotation(Timeout.class);
    if (timeoutAnn != null) {
View Full Code Here


        .isPublic()
        .isNotStatic()
        .hasArgsCount(0);

      // No @Test(timeout=...) and @Timeout at the same time.
      Test testAnn = method.getAnnotation(Test.class);
      if (testAnn != null && testAnn.timeout() > 0 && method.isAnnotationPresent(Timeout.class)) {
        throw new IllegalArgumentException("Conflicting @Test(timeout=...) and @Timeout " +
            "annotations in: " + suiteClass.getName() + "#" + method.getName());
      }

      // @Seed annotation on test methods must have at most 1 seed value.
View Full Code Here

  /**
   * Wrap the given statement into another catching the expected exception, if declared.
   */
  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

          // could be private, i.e. not a test method
          // could have arguments, not handled
          continue;
        }

        Test annotation = method.getAnnotation(Test.class);
        if (annotation != null)
          return methodName;
      }
    } catch (ClassNotFoundException shouldNeverOccur) {
      // Fall through and crash.
View Full Code Here

    return resStatement;
  }

    protected Statement possiblyExpectingExceptions(FrameworkMethod method,
            Object test, Statement next) {
        Test annotation = method.getAnnotation(Test.class);
        return expectsException(annotation) ? new QCCheckExpectException(next,
                getExpectedException(annotation)) : next;
    }
View Full Code Here

      }

      @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

          }
      }

      @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

            initMethodObjects(this.testObject);
            final Method m = getMethod(this.testObject,methodName);
            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() {
                    @Override
View Full Code Here

    {
        StringBuffer buffer = new StringBuffer();
        Method[] methods = UnitTests.class.getMethods();
        for( Method m : methods )
        {
            Test annot = m.getAnnotation( Test.class );
            if( annot != null && Modifier.isPublic( m.getModifiers() ) )
            {
                try
                {
                    long t0 = System.currentTimeMillis();
View Full Code Here

    {
        StringBuffer buffer = new StringBuffer();
        Method[] methods = UnitTests.class.getMethods();
        for( Method m : methods )
        {
            Test annot = m.getAnnotation( Test.class );
            if( annot != null && Modifier.isPublic( m.getModifiers() ) )
            {
                try
                {
                    long t0 = System.currentTimeMillis();
View Full Code Here

TOP

Related Classes of org.junit.Test

Copyright © 2018 www.massapicom. 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.