use of org.testng.ITestNGMethod in project carina by qaprosoft.
the class DataProviderFactory method getDataProvider.
public static Object[][] getDataProvider(Annotation[] annotations, ITestContext context, ITestNGMethod m) {
Map<String, String> testNameArgsMap = Collections.synchronizedMap(new HashMap<String, String>());
Map<String, String> canonicalTestNameArgsMap = Collections.synchronizedMap(new HashMap<String, String>());
Map<String, String> testMethodNameArgsMap = Collections.synchronizedMap(new HashMap<String, String>());
Map<String, String> testMethodOwnerArgsMap = Collections.synchronizedMap(new HashMap<String, String>());
Map<String, String> jiraArgsMap = Collections.synchronizedMap(new HashMap<String, String>());
Map<String, String> testRailsArgsMap = Collections.synchronizedMap(new HashMap<String, String>());
Map<String, String> bugArgsMap = Collections.synchronizedMap(new HashMap<String, String>());
List<String> doNotRunTests = Collections.synchronizedList(new ArrayList<>());
Object[][] provider = new Object[][] {};
for (Annotation annotation : annotations) {
try {
Class<? extends Annotation> type = annotation.annotationType();
String providerClass = "";
for (Method method : type.getDeclaredMethods()) {
if (method.getName().equalsIgnoreCase("classname")) {
providerClass = (String) method.invoke(annotation);
break;
}
}
if (providerClass.isEmpty())
continue;
Class<?> clazz;
Object object = null;
try {
clazz = Class.forName(providerClass);
Constructor<?> ctor = clazz.getConstructor();
object = ctor.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
BaseDataProvider activeProvider = (BaseDataProvider) object;
if (object instanceof com.qaprosoft.carina.core.foundation.dataprovider.core.impl.BaseDataProvider) {
provider = ArrayUtils.addAll(provider, activeProvider.getDataProvider(annotation, context, m));
testNameArgsMap.putAll(activeProvider.getTestNameArgsMap());
canonicalTestNameArgsMap.putAll(activeProvider.getCanonicalTestNameArgsMap());
testMethodNameArgsMap.putAll(activeProvider.getTestMethodNameArgsMap());
testMethodOwnerArgsMap.putAll(activeProvider.getTestMethodOwnerArgsMap());
jiraArgsMap.putAll(activeProvider.getJiraArgsMap());
testRailsArgsMap.putAll(activeProvider.getTestRailsArgsMap());
bugArgsMap.putAll(activeProvider.getBugArgsMap());
doNotRunTests.addAll(activeProvider.getDoNotRunRowsIDs());
}
} catch (Exception e) {
e.printStackTrace();
// do nothing
}
}
if (!GroupByMapper.getInstanceInt().isEmpty() || !GroupByMapper.getInstanceStrings().isEmpty()) {
provider = getGroupedList(provider);
}
context.setAttribute(SpecialKeywords.TEST_NAME_ARGS_MAP, testNameArgsMap);
context.setAttribute(SpecialKeywords.CANONICAL_TEST_NAME_ARGS_MAP, canonicalTestNameArgsMap);
// TODO: analyze usage and remove TEST_METHOD_NAME_ARGS_MAP feature as soon as possible
context.setAttribute(SpecialKeywords.TEST_METHOD_NAME_ARGS_MAP, testMethodNameArgsMap);
context.setAttribute(SpecialKeywords.TEST_METHOD_OWNER_ARGS_MAP, testMethodOwnerArgsMap);
context.setAttribute(SpecialKeywords.JIRA_ARGS_MAP, jiraArgsMap);
context.setAttribute(SpecialKeywords.TESTRAIL_ARGS_MAP, testRailsArgsMap);
context.setAttribute(SpecialKeywords.BUG_ARGS_MAP, bugArgsMap);
context.setAttribute(SpecialKeywords.DO_NOT_RUN_TESTS, doNotRunTests);
// clear group by settings
GroupByMapper.getInstanceInt().clear();
GroupByMapper.getInstanceStrings().clear();
return provider;
}
use of org.testng.ITestNGMethod in project arrow by NetEase.
the class PowerEmailableReporter method getMethodSet.
/**
* Since the methods will be sorted chronologically, we want to return the
* ITestNGMethod from the invoked methods.
*/
private Collection<ITestNGMethod> getMethodSet(IResultMap tests, ISuite suite) {
List<IInvokedMethod> r = Lists.newArrayList();
List<IInvokedMethod> invokedMethods = suite.getAllInvokedMethods();
// Eliminate the repeat retry methods
for (IInvokedMethod im : invokedMethods) {
if (tests.getAllMethods().contains(im.getTestMethod())) {
int testId = getId(im.getTestResult());
if (!testIds.contains(testId)) {
testIds.add(testId);
r.add(im);
}
}
}
Arrays.sort(r.toArray(new IInvokedMethod[r.size()]), new TestSorter());
List<ITestNGMethod> result = Lists.newArrayList();
// Add all the invoked methods
for (IInvokedMethod m : r) {
result.add(m.getTestMethod());
}
for (ITestResult allResult : tests.getAllResults()) {
int testId = getId(allResult);
if (!testIds.contains(testId)) {
result.add(allResult.getMethod());
}
}
return result;
}
use of org.testng.ITestNGMethod in project arrow by NetEase.
the class PowerEmailableReporter method resultDetail.
private void resultDetail(IResultMap tests) {
for (ITestResult result : tests.getAllResults()) {
ITestNGMethod method = result.getMethod();
int methodId = getId(result);
String cname = method.getTestClass().getName();
m_out.println("<h2 id=\"m" + methodId + "\" name=\"m" + methodId + "\" >" + cname + ":" + method.getMethodName() + "</h2>");
Set<ITestResult> resultSet = tests.getResults(method);
generateForResult(result, method, resultSet.size());
m_out.println("<p class=\"totop\"><a href=\"#summary\">back to summary</a></p>");
}
}
use of org.testng.ITestNGMethod in project java.webdriver by sayems.
the class TestNGListener method onFinish.
@Override
public void onFinish(ITestContext context) {
Iterator<ITestResult> listOfFailedTests = context.getFailedTests().getAllResults().iterator();
while (listOfFailedTests.hasNext()) {
ITestResult failedTest = listOfFailedTests.next();
ITestNGMethod method = failedTest.getMethod();
if (context.getFailedTests().getResults(method).size() > 1) {
listOfFailedTests.remove();
} else {
if (context.getPassedTests().getResults(method).size() > 0) {
listOfFailedTests.remove();
}
}
}
}
use of org.testng.ITestNGMethod in project gradle by gradle.
the class TestNGTestResultProcessorAdapter method onFinish.
@Override
public void onFinish(ITestContext iTestContext) {
Object id;
synchronized (lock) {
id = testId.remove(iTestContext);
xmlTestIds.remove(iTestContext.getCurrentXmlTest());
for (ITestNGMethod method : iTestContext.getAllTestMethods()) {
testMethodParentId.remove(method);
}
}
resultProcessor.completed(id, new TestCompleteEvent(iTestContext.getEndDate().getTime()));
}
Aggregations