org.testng.annotations.Test.dataProvider()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(223)

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

Test.dataProvider介绍

暂无

代码示例

代码示例来源:origin: org.testng/testng

testAnnotation = cm.getMethod().getAnnotation(Test.class);
if (testAnnotation != null) {
 String dataProvider = testAnnotation.dataProvider();
 if (!Strings.isNullOrEmpty(dataProvider)) {
  attributes.setProperty(XMLReporterConfig.ATTR_DATA_PROVIDER, dataProvider);

代码示例来源:origin: org.testng/testng

result.setThreadPoolSize(test.threadPoolSize());
result.setSuccessPercentage(test.successPercentage());
result.setDataProvider(test.dataProvider());

代码示例来源:origin: cbeust/testng

testAnnotation = cm.getMethod().getAnnotation(Test.class);
if (testAnnotation != null) {
 String dataProvider = testAnnotation.dataProvider();
 if (!Strings.isNullOrEmpty(dataProvider)) {
  attributes.setProperty(XMLReporterConfig.ATTR_DATA_PROVIDER, dataProvider);

代码示例来源:origin: cbeust/testng

result.setThreadPoolSize(test.threadPoolSize());
result.setSuccessPercentage(test.successPercentage());
result.setDataProvider(test.dataProvider());
result.setDataProviderClass(
  findInherited(

代码示例来源:origin: org.dspace.dependencies.jmockit/dspace-jmockit

private boolean isMethodWithParametersProvidedByTestNG(Method method)
{
 if (method.isAnnotationPresent(Parameters.class)) {
   return true;
 }
 Test testMetadata = method.getAnnotation(Test.class);
 return testMetadata != null && testMetadata.dataProvider().length() > 0;
}

代码示例来源:origin: com.teradata.tempto/tempto-core

dataProviderClass = method.getRealClass();
String dataProviderName = testAnnotation.dataProvider();
if (dataProviderName.isEmpty()) {
  return Optional.empty();

代码示例来源:origin: org.infinispan/infinispan-commons-test

private String testName(ITestResult res) {
 StringBuilder result = new StringBuilder();
 result.append(res.getInstanceName()).append(".").append(res.getMethod().getMethodName());
 if (res.getMethod().getConstructorOrMethod().getMethod().isAnnotationPresent(Test.class)) {
   String dataProviderName = res.getMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class)
      .dataProvider();
   // Add parameters for methods that use a data provider only
   if (res.getParameters().length != 0 && !dataProviderName.isEmpty()) {
    result.append("(").append(Arrays.deepToString(res.getParameters())).append(")");
   }
 }
 return result.toString();
}

代码示例来源:origin: prestodb/tempto

dataProviderClass = method.getRealClass();
String dataProviderName = testAnnotation.dataProvider();
if (dataProviderName.isEmpty()) {
  return Optional.empty();

代码示例来源:origin: com.consol.citrus/citrus-core

Object[] dataProviderParams = null;
if (method.getAnnotation(Test.class) != null &&
    StringUtils.hasText(method.getAnnotation(Test.class).dataProvider())) {
  final Method[] dataProvider = new Method[1];
  ReflectionUtils.doWithMethods(method.getDeclaringClass(), current -> {
    if (StringUtils.hasText(current.getAnnotation(DataProvider.class).name()) &&
        current.getAnnotation(DataProvider.class).name().equals(method.getAnnotation(Test.class).dataProvider())) {
      dataProvider[0] = current;
    } else if (current.getName().equals(method.getAnnotation(Test.class).dataProvider())) {
      dataProvider[0] = current;
    throw new CitrusRuntimeException("Unable to find data provider: " + method.getAnnotation(Test.class).dataProvider());

代码示例来源:origin: org.infinispan/infinispan-commons-test

if (res.getMethod().getConstructorOrMethod().getMethod().isAnnotationPresent(Test.class)) {
  String dataProviderName = res.getMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class)
     .dataProvider();

代码示例来源:origin: com.epam.reportportal/agent-java-testng

/**
 * Extension point to customize Report Portal test parameters
 *
 * @param testResult TestNG's testResult context
 * @return Test/Step Parameters being sent to Report Portal
 */
protected List<ParameterResource> createStepParameters(ITestResult testResult) {
  List<ParameterResource> parameters = Lists.newArrayList();
  Test testAnnotation = getMethodAnnotation(Test.class, testResult);
  Parameters parametersAnnotation = getMethodAnnotation(Parameters.class, testResult);
  if (null != testAnnotation && !isNullOrEmpty(testAnnotation.dataProvider())) {
    parameters = createDataProviderParameters(testResult);
  } else if (null != parametersAnnotation) {
    parameters = createAnnotationParameters(testResult, parametersAnnotation);
  }
  return parameters.isEmpty() ? null : parameters;
}

代码示例来源:origin: paypal/SeLion

private boolean isLowPriority(IInvokedMethod method) {
  int low = method.getTestMethod().getPriority();
  for (ITestNGMethod test : method.getTestMethod().getTestClass().getTestMethods()) {
    // ensures all test methods have the @Test annotation. Throw exception if that's not the case
    if (!isAnnotatedWithTest(test.getConstructorOrMethod().getMethod())) {
      throw new IllegalStateException(
          "Session sharing requires all test methods to define a priority via the @Test annotation.");
    }
    if (test.getEnabled() && test.getPriority() < low) {
      return false;
    }
  }
  Test t = method.getTestMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class);
  // If there is an existing session and the test method has a DP then don't create a session
  // For a data driven test method with the first data the session must be created
  // Hence return true if currentInvocationCount is 1 otherwise utilize the same session
  // by returning false
  int currentInvocationCount = method.getTestMethod().getCurrentInvocationCount();
  if (!t.dataProvider().isEmpty()) {
    return currentInvocationCount == 0;
  }
  return true;
}

代码示例来源:origin: com.qaprosoft/zafira-client

if (!((Test) a).dataProvider().isEmpty())

代码示例来源:origin: qaprosoft/zafira

if (!((Test) a).dataProvider().isEmpty())

代码示例来源:origin: paypal/SeLion

private boolean isHighPriority(IInvokedMethod method) {
  if (!isAnnotatedWithTest(method)) {
    // Abort. There will already be an exception thrown in isLowPriority for this case.
    return true;
  }
  int high = method.getTestMethod().getPriority();
  for (ITestNGMethod test : method.getTestMethod().getTestClass().getTestMethods()) {
    if (test.getEnabled() && test.getPriority() > high) {
      return false;
    }
  }
  Test t = method.getTestMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class);
  // For a test method with a data provider
  if (!(t.dataProvider().isEmpty())) {
    int currentInvocationCount = method.getTestMethod().getCurrentInvocationCount();
    int parameterInvocationCount = method.getTestMethod().getParameterInvocationCount();
    // If the data set from the data provider is exhausted
    // It means its the last method with the data provider- this is the exit condition
    return (currentInvocationCount == parameterInvocationCount);
  }
  return true;
}

相关文章