org.junit.runners.Parameterized.getTestClass()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.junit.runners.Parameterized.getTestClass()方法的一些代码示例,展示了Parameterized.getTestClass()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parameterized.getTestClass()方法的具体详情如下:
包路径:org.junit.runners.Parameterized
类名称:Parameterized
方法名:getTestClass

Parameterized.getTestClass介绍

暂无

代码示例

代码示例来源:origin: google/j2objc

private List<FrameworkField> getAnnotatedFieldsByParameter() {
  return getTestClass().getAnnotatedFields(Parameter.class);
}

代码示例来源:origin: google/j2objc

private FrameworkMethod getParametersMethod() throws Exception {
  List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(
      Parameters.class);
  for (FrameworkMethod each : methods) {
    if (each.isStatic() && each.isPublic()) {
      return each;
    }
  }
  throw new Exception("No public static parameters method on class "
      + getTestClass().getName());
}

代码示例来源:origin: google/j2objc

private Exception parametersMethodReturnedWrongType() throws Exception {
  String className = getTestClass().getName();
  String methodName = getParametersMethod().getName();
  String message = MessageFormat.format(
      "{0}.{1}() must return an Iterable of arrays.",
      className, methodName);
  return new Exception(message);
}

代码示例来源:origin: junit-team/junit4

private void validatePublicStaticVoidMethods(
    Class<? extends Annotation> annotation, Integer parameterCount,
    List<Throwable> errors) {
  List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation);
  for (FrameworkMethod fm : methods) {
    fm.validatePublicVoid(true, errors);
    if (parameterCount != null) {
      int methodParameterCount = fm.getMethod().getParameterTypes().length;
      if (methodParameterCount != 0 && methodParameterCount != parameterCount) {
        errors.add(new Exception("Method " + fm.getName()
            + "() should have 0 or " + parameterCount + " parameter(s)"));
      }
    }
  }
}

代码示例来源:origin: junit-team/junit4

private void validateBeforeParamAndAfterParamMethods(Integer parameterCount)
    throws InvalidTestClassError {
  List<Throwable> errors = new ArrayList<Throwable>();
  validatePublicStaticVoidMethods(Parameterized.BeforeParam.class, parameterCount, errors);
  validatePublicStaticVoidMethods(Parameterized.AfterParam.class, parameterCount, errors);
  if (!errors.isEmpty()) {
    throw new InvalidTestClassError(getTestClass().getJavaClass(), errors);
  }
}

代码示例来源:origin: google/j2objc

private void createRunnersForParameters(Iterable<Object[]> allParameters,
    String namePattern) throws InitializationError, Exception {
  try {
    int i = 0;
    for (Object[] parametersOfSingleTest : allParameters) {
      String name = nameFor(namePattern, i, parametersOfSingleTest);
      TestClassRunnerForParameters runner = new TestClassRunnerForParameters(
          getTestClass().getJavaClass(), parametersOfSingleTest,
          name);
      runners.add(runner);
      ++i;
    }
  } catch (ClassCastException e) {
    throw parametersMethodReturnedWrongType();
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

private List<FrameworkField> getAnnotatedFieldsByParameter() {
  return getTestClass().getAnnotatedFields(Parameter.class);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private FrameworkMethod getParametersMethod() throws Exception {
  List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(
      Parameters.class);
  for (FrameworkMethod each : methods) {
    if (each.isStatic() && each.isPublic()) {
      return each;
    }
  }
  throw new Exception("No public static parameters method on class "
      + getTestClass().getName());
}

代码示例来源:origin: camunda/camunda-bpm-platform

private Exception parametersMethodReturnedWrongType() throws Exception {
  String className = getTestClass().getName();
  String methodName = getParametersMethod().getName();
  String message = MessageFormat.format(
      "{0}.{1}() must return an Iterable of arrays.",
      className, methodName);
  return new Exception(message);
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void createRunnersForParameters(Iterable<Object[]> allParameters,
    String namePattern) throws InitializationError, Exception {
  try {
    int i = 0;
    for (Object[] parametersOfSingleTest : allParameters) {
      String name = nameFor(namePattern, i, parametersOfSingleTest);
      TestClassRunnerForParameters runner = new TestClassRunnerForParameters(
          getTestClass().getJavaClass(), parametersOfSingleTest,
          name);
      runners.add(runner);
      ++i;
    }
  } catch (ClassCastException e) {
    throw parametersMethodReturnedWrongType();
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.junit

private TestWithParameters createTestWithNotNormalizedParameters(
    String pattern, int index, Object parametersOrSingleParameter) {
  Object[] parameters= (parametersOrSingleParameter instanceof Object[]) ? (Object[]) parametersOrSingleParameter
    : new Object[] { parametersOrSingleParameter };
  return createTestWithParameters(getTestClass(), pattern, index,
      parameters);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

private TestWithParameters createTestWithNotNormalizedParameters(
    String pattern, int index, Object parametersOrSingleParameter) {
  Object[] parameters= (parametersOrSingleParameter instanceof Object[]) ? (Object[]) parametersOrSingleParameter
    : new Object[] { parametersOrSingleParameter };
  return createTestWithParameters(getTestClass(), pattern, index,
      parameters);
}

代码示例来源:origin: org.junit/com.springsource.org.junit

private FrameworkMethod getParametersMethod() throws Exception {
  List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(
      Parameters.class);
  for (FrameworkMethod each : methods) {
    if (each.isStatic() && each.isPublic()) {
      return each;
    }
  }
  throw new Exception("No public static parameters method on class "
      + getTestClass().getName());
}

代码示例来源:origin: com.oracle/truffle-tck

private FrameworkMethod getParametersMethod() throws Exception {
  List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(
      Parameters.class);
  for (FrameworkMethod each : methods) {
    if (each.isStatic() && each.isPublic()) {
      return each;
    }
  }
  throw new Exception("No public static parameters method on class "
      + getTestClass().getName());
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.junit

private FrameworkMethod getParametersMethod() throws Exception {
  List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(
      Parameters.class);
  for (FrameworkMethod each : methods) {
    if (each.isStatic() && each.isPublic()) {
      return each;
    }
  }
  throw new Exception("No public static parameters method on class "
      + getTestClass().getName());
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

private FrameworkMethod getParametersMethod() throws Exception {
  List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(
      Parameters.class);
  for (FrameworkMethod each : methods) {
    if (each.isStatic() && each.isPublic()) {
      return each;
    }
  }
  throw new Exception("No public static parameters method on class "
      + getTestClass().getName());
}

代码示例来源:origin: org.junit/com.springsource.org.junit

private Exception parametersMethodReturnedWrongType() throws Exception {
  String className = getTestClass().getName();
  String methodName = getParametersMethod().getName();
  String message = MessageFormat.format(
      "{0}.{1}() must return an Iterable of arrays.",
      className, methodName);
  return new Exception(message);
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.junit

private Exception parametersMethodReturnedWrongType() throws Exception {
  String className = getTestClass().getName();
  String methodName = getParametersMethod().getName();
  String message = MessageFormat.format(
      "{0}.{1}() must return an Iterable of arrays.",
      className, methodName);
  return new Exception(message);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

private Exception parametersMethodReturnedWrongType() throws Exception {
  String className = getTestClass().getName();
  String methodName = getParametersMethod().getName();
  String message = MessageFormat.format(
      "{0}.{1}() must return an Iterable of arrays.",
      className, methodName);
  return new Exception(message);
}

代码示例来源:origin: com.oracle/truffle-tck

private Exception parametersMethodReturnedWrongType() throws Exception {
  String className = getTestClass().getName();
  String methodName = getParametersMethod().getName();
  String message = MessageFormat.format(
      "{0}.{1}() must return an Iterable of arrays.",
      className, methodName);
  return new Exception(message);
}

相关文章