org.junit.runners.model.FrameworkMethod#validatePublicVoid()源码实例Demo

下面列出了org.junit.runners.model.FrameworkMethod#validatePublicVoid() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: vertx-unit   文件: VertxUnitRunner.java
@Override
protected void validatePublicVoidNoArgMethods(Class<? extends Annotation> annotation, boolean isStatic, List<Throwable> errors) {
  if (annotation == Test.class || annotation == Before.class || annotation == After.class ||
      annotation == BeforeClass.class || annotation == AfterClass.class) {
    List<FrameworkMethod> fMethods = getTestClass().getAnnotatedMethods(annotation);
    for (FrameworkMethod fMethod : fMethods) {
      fMethod.validatePublicVoid(isStatic, errors);
      try {
        validateTestMethod(fMethod);
      } catch (Exception e) {
        errors.add(e);
      }
    }
  } else {
    super.validatePublicVoidNoArgMethods(annotation, isStatic, errors);
  }
}
 
源代码2 项目: junit-dataprovider   文件: TestValidator.java
/**
 * Checks if the given {@code testMethod} is a valid test method depending on the dataprovider relevant annotation
 * {@code @}{@link DataProvider} and {@code @}{@link UseDataProvider}. Adds {@link Exception}s to {@code errors} for
 * each invalid property. A normal test method must be is public, void instance method with no arguments. A data
 * provider test method must be is public and void instance method but have a least one argument.
 *
 * @param testMethod the test method to be validated
 * @param errors to be "returned" and thrown as {@link InitializationError}
 * @throws IllegalArgumentException if given {@code errors} is {@code null}
 */
public void validateTestMethod(FrameworkMethod testMethod, List<Throwable> errors) {
    checkNotNull(testMethod, "testMethod must not be null");
    checkNotNull(errors, "errors must not be null");

    UseDataProvider useDataProvider = testMethod.getAnnotation(UseDataProvider.class);
    DataProvider dataProvider = testMethod.getAnnotation(DataProvider.class);

    if (useDataProvider != null && dataProvider != null) {
        errors.add(new Exception(String.format("Method %s() should either have @%s or @%s annotation", testMethod
                .getName(), useDataProvider.getClass().getSimpleName(), dataProvider.getClass().getSimpleName())));

    } else if (useDataProvider == null && dataProvider == null) {
        testMethod.validatePublicVoidNoArg(false, errors);

    } else {
        testMethod.validatePublicVoid(false, errors);
        if (testMethod.getMethod().getParameterTypes().length <= 0) {
            errors.add(new Exception(String.format("Method %s() must have at least one argument for dataprovider",
                    testMethod.getName())));
        }
    }
}
 
源代码3 项目: JQF   文件: JQF.java
private void validateFuzzMethods(List<Throwable> errors) {
    for (FrameworkMethod method : getTestClass().getAnnotatedMethods(Fuzz.class)) {
        method.validatePublicVoid(false, errors);
        if (method.getAnnotation(Property.class) != null) {
            errors.add(new Exception("Method " + method.getName() +
                    " cannot have both @Property and @Fuzz annotations"));
        }
    }
}
 
源代码4 项目: registry   文件: CustomParameterizedRunner.java
private void validatePublicStaticVoidMethods(Class<? extends Annotation> annotation,
                                             List<Throwable> errors) {
    final List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation);
    for (FrameworkMethod eachTestMethod : methods) {
        eachTestMethod.validatePublicVoid(true, errors);
    }
}
 
源代码5 项目: registry   文件: CustomParameterizedRunner.java
private void validatePublicStaticVoidMethods(Class<? extends Annotation> annotation,
                                             List<Throwable> errors) {
    final List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation);
    for (FrameworkMethod eachTestMethod : methods) {
        eachTestMethod.validatePublicVoid(true, errors);
    }
}
 
源代码6 项目: bazel   文件: DesugarRunner.java
/**
 * In replacement of {@link BlockJUnit4ClassRunner#validatePublicVoidNoArgMethods} for @Test
 * method signature validation.
 */
private void validatePublicVoidMethodsWithInjectableArgs(
    Class<? extends Annotation> annotation, boolean isStatic, List<Throwable> errors) {
  List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation);
  for (FrameworkMethod eachTestMethod : methods) {
    eachTestMethod.validatePublicVoid(isStatic, errors);
    validateInjectableParameters(eachTestMethod, errors);
    validateParameterValueSource(eachTestMethod, errors);
  }
}
 
源代码7 项目: datakernel   文件: DatakernelRunner.java
@Override
protected void validatePublicVoidNoArgMethods(Class<? extends Annotation> annotation, boolean isStatic, List<Throwable> errors) {
	for (FrameworkMethod testMethod : getTestClass().getAnnotatedMethods(annotation)) {
		testMethod.validatePublicVoid(isStatic, errors);
	}
}
 
源代码8 项目: buck   文件: EndToEndRunner.java
/**
 * Marks validation errors in errors if:
 *
 * <ul>
 *   <li>Any method marked by @Test is a not a public non-static void method.
 *   <li>Any method marked by @Test does not have exact args ({@link EndToEndTestDescriptor},
 *       {@link ProcessResult})
 * </ul>
 */
private void validateTestMethods(List<Throwable> errors) {
  List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(Test.class);

  for (FrameworkMethod testMethod : methods) {
    testMethod.validatePublicVoid(false, errors);
    validateTestMethodArgs(testMethod, errors);
  }
}