Package org.junit.runners.model

Examples of org.junit.runners.model.FrameworkMethod


                    throw new RuntimeException("Test Class should not be loaded");
                }

                final HelperTestRunner helperTestRunner = new HelperTestRunner(bootstrappedTestClass);
                final Method bootstrappedMethod = bootstrappedTestClass.getMethod(method.getName());
                final Statement statement = helperTestRunner.methodBlock(new FrameworkMethod(bootstrappedMethod));
                statement.evaluate();
            }
        };
    }
View Full Code Here


        return Arrays.asList(columnNames);
    }

    public FrameworkMethod getTestDataMethod() throws Exception {
        FrameworkMethod method = findTestDataMethod();
        if (method == null) {
            throw new IllegalArgumentException("No public static @FilePathParser method on class "
                    + testClass.getName());
        }
        return method;
View Full Code Here

    @Test(expected = IllegalStateException.class)
    public void should_raise_runtime_exception_if_it_cant_instanciate_the_spring_context() throws Exception {
        TestableSpringIntegration testableSpringIntegration = new TestableSpringIntegration();

        Method testMethod = this.getClass().getMethod("should_raise_runtime_exception_if_it_cant_instanciate_the_spring_context");
        FrameworkMethod method = new FrameworkMethod(testMethod);
        doThrow(new Exception()).when(testContextManager).prepareTestInstance(target);

        testableSpringIntegration.apply(statement, method, target);
    }
View Full Code Here

    final static class CSVDataDrivenTestScenario {}

    @Test
    public void the_parameterized_data_method_is_annotated_by_the_TestData_annotation() throws Exception {
        TestClass testClass = new TestClass(DataDrivenTestScenario.class);
        FrameworkMethod method = DataDrivenAnnotations.forClass(testClass).getTestDataMethod();

        assertThat(method.getName(), is("testData"));

    }
View Full Code Here

        }
    }
    @Test(expected = IllegalArgumentException.class)
    public void the_parameterized_data_method_must_be_public() throws Exception {
        TestClass testClass = new TestClass(DataDrivenTestScenarioWithPrivateTestData.class);
        FrameworkMethod method = DataDrivenAnnotations.forClass(testClass).getTestDataMethod();

        assertThat(method.getName(), is("testData"));

    }
View Full Code Here

    }

    @Test(expected = IllegalArgumentException.class)
    public void the_parameterized_data_method_must_be_static() throws Exception {
        TestClass testClass = new TestClass(DataDrivenTestScenarioWithNonStaticTestData.class);
        FrameworkMethod method = DataDrivenAnnotations.forClass(testClass).getTestDataMethod();

        assertThat(method.getName(), is("testData"));
    }
View Full Code Here

   * Wrap the given statement in any declared MethodRules.
   */
  @SuppressWarnings("deprecation")
  private Statement wrapMethodRules(Statement s, TestCandidate c, Object instance) {
    TestClass info = new TestClass(suiteClass);
    FrameworkMethod fm = new FrameworkMethod(c.method);
    for (org.junit.rules.MethodRule each :
        info.getAnnotatedFieldValues(suiteClass, Rule.class, org.junit.rules.MethodRule.class))
      s = each.apply(s, fm, instance);
    return s;
  }
View Full Code Here

            m.getParameterTypes().length == 0 &&
            m.getReturnType() == Void.TYPE))
        {
          if (Modifier.isStatic(mod))
            throw new RuntimeException("Test methods must not be static.");
          testMethods.add(new FrameworkMethod(m));
        }
      }
     
      if (testMethods.isEmpty()) {
        throw new RuntimeException("No runnable methods!");
      }
     
      if (TEST_NIGHTLY == false) {
        if (getTestClass().getJavaClass().isAnnotationPresent(Nightly.class)) {
          /* the test class is annotated with nightly, remove all methods */
          String className = getTestClass().getJavaClass().getSimpleName();
          System.err.println("NOTE: Ignoring nightly-only test class '" + className + "'");
          testMethods.clear();
        } else {
          /* remove all nightly-only methods */
          for (int i = 0; i < testMethods.size(); i++) {
            final FrameworkMethod m = testMethods.get(i);
            if (m.getAnnotation(Nightly.class) != null) {
              System.err.println("NOTE: Ignoring nightly-only test method '" + m.getName() + "'");
              testMethods.remove(i--);
            }
          }
        }
        /* dodge a possible "no-runnable methods" exception by adding a fake ignored test */
        if (testMethods.isEmpty()) {
          try {
            testMethods.add(new FrameworkMethod(LuceneTestCase.class.getMethod("alwaysIgnoredTestMethod")));
          } catch (Exception e) { throw new RuntimeException(e); }
        }
      }
      return testMethods;
    }
View Full Code Here

  }

  public Parameterized(Class<?> clazz) throws Throwable {
    super(clazz, new ArrayList<Runner>());

    FrameworkMethod method = findMethod(getTestClass());
    List<Object[]> parametersList = (List<Object[]>) method.invokeExplosively(null);
    for (int i = 0; i < parametersList.size(); i++)
      getChildren().add(new ClassRunnerForParameters(getTestClass().getJavaClass(), parametersList.get(i)));
  }
View Full Code Here

              m.getParameterTypes().length == 0 &&
              m.getReturnType() == Void.TYPE))
      {
        if (Modifier.isStatic(mod))
          throw new RuntimeException("Test methods must not be static.");
        testMethods.add(new FrameworkMethod(m));
      }
    }
   
    if (testMethods.isEmpty()) {
      throw new RuntimeException("No runnable methods!");
    }
   
    if (TEST_NIGHTLY == false) {
      if (getTestClass().getJavaClass().isAnnotationPresent(Nightly.class)) {
        /* the test class is annotated with nightly, remove all methods */
        String className = getTestClass().getJavaClass().getSimpleName();
        System.err.println("NOTE: Ignoring nightly-only test class '" + className + "'");
        testMethods.clear();
      } else {
        /* remove all nightly-only methods */
        for (int i = 0; i < testMethods.size(); i++) {
          final FrameworkMethod m = testMethods.get(i);
          if (m.getAnnotation(Nightly.class) != null) {
            System.err.println("NOTE: Ignoring nightly-only test method '" + m.getName() + "'");
            testMethods.remove(i--);
          }
        }
      }
      /* dodge a possible "no-runnable methods" exception by adding a fake ignored test */
      if (testMethods.isEmpty()) {
        try {
          testMethods.add(new FrameworkMethod(LuceneTestCase.class.getMethod("alwaysIgnoredTestMethod")));
        } catch (Exception e) { throw new RuntimeException(e); }
      }
    }
    // sort the test methods first before shuffling them, so that the shuffle is consistent
    // across different implementations that might order the methods different originally.
View Full Code Here

TOP

Related Classes of org.junit.runners.model.FrameworkMethod

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.