results.put("passed", testContext.getPassedTests());
results.put("failed", testContext.getFailedTests());
results.put("failedBut", testContext.getFailedButWithinSuccessPercentageTests());
results.put("skipped", testContext.getSkippedTests());
ResultMap total = new ResultMap();
addAll( total, results.get("passed") );
addAll( total, results.get("failed") );
addAll( total, results.get("failedBut") );
addAll( total, results.get("skipped") );
ITestNGMethod[] allMethodsInCtx = testContext.getAllTestMethods();
for (int i = 0; i < allMethodsInCtx.length; i++)
{
ITestNGMethod methodInCtx = allMethodsInCtx [ i ];
Collection<ITestNGMethod> allMethodsFound = total.getAllMethods();
boolean exists = false;
for( ITestNGMethod methodFound : allMethodsFound )
{
if ( methodInCtx.getTestClass().getName().equals(methodFound.getTestClass().getName()))
{
if ( methodInCtx.getMethod().getName().equals(methodFound.getMethod().getName()))
{
exists = true;
}
}
}
if ( ! exists )
{
ITestResult skippedTestResult =
new org.testng.internal.TestResult(methodInCtx.getTestClass(), methodInCtx.getInstances(), methodInCtx, null, testContext.getStartDate().getTime(), testContext.getEndDate().getTime());
skippedTestResult.setStatus(ITestResult.SKIP);
total.addResult(skippedTestResult, methodInCtx);
}
}
List<ITestResult> testNGTestResults = new ArrayList<ITestResult>(total.getAllResults() );
Collections.sort(testNGTestResults, EXECUTION_DATE_COMPARATOR);
return testNGTestResults;
}