testAnnotation = cm.getMethod().getAnnotation(Test.class); if (testAnnotation != null) { String dataProvider = testAnnotation.dataProvider(); if (!Strings.isNullOrEmpty(dataProvider)) { attributes.setProperty(XMLReporterConfig.ATTR_DATA_PROVIDER, dataProvider);
result.setThreadPoolSize(test.threadPoolSize()); result.setSuccessPercentage(test.successPercentage()); result.setDataProvider(test.dataProvider());
testAnnotation = cm.getMethod().getAnnotation(Test.class); if (testAnnotation != null) { String dataProvider = testAnnotation.dataProvider(); if (!Strings.isNullOrEmpty(dataProvider)) { attributes.setProperty(XMLReporterConfig.ATTR_DATA_PROVIDER, dataProvider);
result.setThreadPoolSize(test.threadPoolSize()); result.setSuccessPercentage(test.successPercentage()); result.setDataProvider(test.dataProvider()); result.setDataProviderClass( findInherited(
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; }
dataProviderClass = method.getRealClass(); String dataProviderName = testAnnotation.dataProvider(); if (dataProviderName.isEmpty()) { return Optional.empty();
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(); }
dataProviderClass = method.getRealClass(); String dataProviderName = testAnnotation.dataProvider(); if (dataProviderName.isEmpty()) { return Optional.empty();
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());
if (res.getMethod().getConstructorOrMethod().getMethod().isAnnotationPresent(Test.class)) { String dataProviderName = res.getMethod().getConstructorOrMethod().getMethod().getAnnotation(Test.class) .dataProvider();
/** * 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; }
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; }
if (!((Test) a).dataProvider().isEmpty())
if (!((Test) a).dataProvider().isEmpty())
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; }