static int getNumParameters(Class<?> clazz) {
    RunWith[] runWiths = clazz.getAnnotationsByType(RunWith.class);
    boolean testParameterized = runWiths != null
      && Arrays.stream(runWiths).anyMatch((r) -> r.value().equals(Parameterized.class));
    if (!testParameterized) {
      return 1;
    }
    for (Method method : clazz.getMethods()) {
      if (!isParametersMethod(method)) {
        continue;
      }
      // Found the parameters method. Figure out the number of parameters.
      Object parameters;
      try {
        parameters = method.invoke(clazz);
      } catch (IllegalAccessException | InvocationTargetException e) {
        LOG.warn("Error invoking parameters method {} in test class {}", method.getName(), clazz,
          e);
        continue;
      }
      if (parameters instanceof List) {
        return ((List) parameters).size();
      } else if (parameters instanceof Collection) {
        return ((Collection) parameters).size();
      } else if (parameters instanceof Iterable) {
        return Iterables.size((Iterable) parameters);
      } else if (parameters instanceof Object[]) {
        return ((Object[]) parameters).length;
      }
    }
    LOG.warn("Unable to determine parameters size. Returning the default of 1.");
    return 1;
  }
@param clazz Test class that is running.
@return the number of parameters for this given test class. If the test is not parameterized or
        if there is any issue determining the number of parameters, returns 1.
hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseClassTestRule.java