use of org.testng.ITestResult in project tomee by apache.
the class HTMLReporter method doWrap.
private List<ITestResult> doWrap(final List<ITestResult> raw) {
final List<ITestResult> wrapped = new ArrayList<>(raw.size());
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
for (final ITestResult result : raw) {
wrapped.add(ITestResult.class.cast(Proxy.newProxyInstance(loader, API, new InvocationHandler() {
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
if (method.getName().equals("getParameters")) {
return new Object[method.getParameterTypes().length];
}
return method.invoke(result, args);
}
})));
}
return wrapped;
}
use of org.testng.ITestResult in project arrow by NetEase.
the class NeXMLSuiteResultWriter method buildTestClassGroups.
private Map<String, List<ITestResult>> buildTestClassGroups(Set<ITestResult> testResults) {
Map<String, List<ITestResult>> map = Maps.newHashMap();
for (ITestResult result : testResults) {
String className = result.getTestClass().getName();
List<ITestResult> list = map.get(className);
if (list == null) {
list = Lists.newArrayList();
map.put(className, list);
}
list.add(result);
}
return map;
}
use of org.testng.ITestResult 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.ITestResult 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.ITestResult in project arrow by NetEase.
the class TestResultListener method onFinish.
@Override
public void onFinish(ITestContext testContext) {
super.onFinish(testContext);
// List of test results which we will delete later
ArrayList<ITestResult> testsToBeRemoved = new ArrayList<ITestResult>();
// collect all id's from passed test
Set<Integer> passedTestIds = new HashSet<Integer>();
for (ITestResult passedTest : testContext.getPassedTests().getAllResults()) {
logger.info("PassedTests = " + passedTest.getName());
passedTestIds.add(getId(passedTest));
}
// Eliminate the repeat methods
Set<Integer> skipTestIds = new HashSet<Integer>();
for (ITestResult skipTest : testContext.getSkippedTests().getAllResults()) {
logger.info("skipTest = " + skipTest.getName());
// id = class + method + dataprovider
int skipTestId = getId(skipTest);
if (skipTestIds.contains(skipTestId) || passedTestIds.contains(skipTestId)) {
testsToBeRemoved.add(skipTest);
} else {
skipTestIds.add(skipTestId);
}
}
// Eliminate the repeat failed methods
Set<Integer> failedTestIds = new HashSet<Integer>();
for (ITestResult failedTest : testContext.getFailedTests().getAllResults()) {
logger.info("failedTest = " + failedTest.getName());
// id = class + method + dataprovider
int failedTestId = getId(failedTest);
// version
if (failedTestIds.contains(failedTestId) || passedTestIds.contains(failedTestId) || skipTestIds.contains(failedTestId)) {
testsToBeRemoved.add(failedTest);
} else {
failedTestIds.add(failedTestId);
}
}
// finally delete all tests that are marked
for (Iterator<ITestResult> iterator = testContext.getFailedTests().getAllResults().iterator(); iterator.hasNext(); ) {
ITestResult testResult = iterator.next();
if (testsToBeRemoved.contains(testResult)) {
logger.info("Remove repeat Fail Test: " + testResult.getName());
iterator.remove();
}
}
}
Aggregations