Package org.junit.runners.model

Examples of org.junit.runners.model.FrameworkMethod


  }

  private void gatherRunnableMethods() {
    for(Method method : testClass.getMethods()) {
      if(isRunnable(method)) {
        runnableMethods.add(new FrameworkMethod(method));
      }
    }
  }
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

            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

    private static void testFrameworkMethod(ReifiedParamRunner runner, Class<?> testClass, String testMethod,
                                            boolean expectedToPass)
    {
        String frameworkMethodString = "public void " + testClass.getName() + "." + testMethod + "()";
        FrameworkMethod method = runner.getChild(frameworkMethodString);
        assertNotNull(frameworkMethodString, method);
        assertEquals(frameworkMethodString, expectedToPass, runner.expectedToPass(method));
    }
View Full Code Here

        {
            throw new Exception("class " + cls.getName() + " must have exactly 1 method annotated with "
                + TestParameters.class.getSimpleName() +"; found " + methods.size());
        }

        FrameworkMethod method = methods.get(0);
        checkParameterizationMethod(method);

        @SuppressWarnings("unchecked")
        Collection<Parameterization> ret = (Collection<Parameterization>) method.invokeExplosively(null);
        checkParameterizations(ret);
        return ret;
    }
View Full Code Here

        @Override
        protected List<FrameworkMethod> getChildren() {
            List<FrameworkMethod> ret = super.getChildren();
            for(ListIterator<FrameworkMethod> iter = ret.listIterator(); iter.hasNext(); ) {
                FrameworkMethod frameworkMethod = iter.next();
                try {
                    if (!onlyIfFilter(frameworkMethod)) {
                        iter.remove();
                    }
                } catch (OnlyIfException e) {
                    iter.set(new OnlyIfErrorFrameworkMethod(frameworkMethod.getMethod(), e));
                }
            }
            return ret;
        }
View Full Code Here

  }

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

    FrameworkMethod method = findMethod(getTestClass());
    List<Object[]> parametersList = null;
    try {
      parametersList = (List<Object[]>) method.invokeExplosively(null);
    } catch (Throwable throwable) {
      throw new Exception(throwable);
    }
    for (Object[] aParametersList : parametersList) {
      getChildren().add(new ClassRunnerForParameters(getTestClass().getJavaClass(), aParametersList));
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

    private void fillChildren() {
        Set<TestAddress> targets = stagedReactor.getTargets();
        TestDirectory testDirectory = TestDirectory.getInstance();
        boolean mangleMethodNames = manager.getNumConfigurations() > 1;
        for (TestAddress address : targets) {
            FrameworkMethod frameworkMethod = (FrameworkMethod) manager.lookupTestMethod(address
                .root());

            // The reactor may contain targets which do not belong to the current test class
            if (frameworkMethod == null) {
                continue;
            }
            Class<?> frameworkMethodClass = frameworkMethod.getMethod().getDeclaringClass();
            String className = getTestClass().getJavaClass().getName();
            String methodName = frameworkMethod.getName();

            if (frameworkMethodClass.isAssignableFrom(getTestClass().getJavaClass())) {
                FrameworkMethod method = mangleMethodNames ? new DecoratedFrameworkMethod(address,
                    frameworkMethod) : frameworkMethod;
                testDirectory.add(address, new TestInstantiationInstruction(className + ";"
                    + methodName));

                methodToTestAddressMap.put(method, address);
View Full Code Here

    private void fillChildren() {
        Set<TestAddress> targets = stagedReactor.getTargets();
        TestDirectory testDirectory = TestDirectory.getInstance();
        for (TestAddress address : targets) {
            FrameworkMethod frameworkMethod = (FrameworkMethod) manager.lookupTestMethod(address
                .root());

            // The reactor may contain targets which do not belong to the current test class
            if (frameworkMethod == null) {
                continue;
            }
            Class<?> frameworkMethodClass = frameworkMethod.getMethod().getDeclaringClass();
            String className = frameworkMethodClass.getName();
            String methodName = frameworkMethod.getName();

            if (frameworkMethodClass.isAssignableFrom(getTestClass().getJavaClass())) {
                FrameworkMethod method = new ParameterizedFrameworkMethod(address, frameworkMethod);
                testDirectory.add(address, new TestInstantiationInstruction(className + ";"
                    + methodName));

                methodToTestAddressMap.put(method, address);
            }
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.