/** * 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(); for (IInvokedMethod im : invokedMethods) { if (tests.getAllMethods().contains(im.getTestMethod())) { 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()); } // Add all the methods that weren't invoked (e.g. skipped) that we // haven't added yet for (ITestNGMethod m : tests.getAllMethods()) { if (!result.contains(m)) { result.add(m); } } return result; }
/** * 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(); for (IInvokedMethod im : invokedMethods) { if (tests.getAllMethods().contains(im.getTestMethod())) { 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()); } // Add all the methods that weren't invoked (e.g. skipped) that we // haven't added yet for (ITestNGMethod m : tests.getAllMethods()) { if (!result.contains(m)) { result.add(m); } } return result; }
private static void generateReport(String name, ISuiteResult suiteResult) { ITestContext ctx = suiteResult.getTestContext(); IResultMap failedConfigs = ctx.getFailedConfigurations(); boolean hasFailedConfigs = !failedConfigs.getAllMethods().isEmpty(); IResultMap failedTests = ctx.getFailedTests(); boolean hasFailedTests = !failedTests.getAllResults().isEmpty(); if (!hasFailedConfigs && !hasFailedTests) { return; } if (hasFailedConfigs) { System.err.println(Strings.repeat("=", 100)); System.err.println("::::::Failed Configurations for Suite ::: [" + name + "] ::: Test name [" + ctx.getName() + "]::::::"); System.err.println(Strings.repeat("=", 100)); failedConfigs.getAllResults().forEach(FailedInformationOnConsoleReporter::generateReport); System.err.println(Strings.repeat("=", 100)); System.err.println("\n\n"); } if (hasFailedTests) { System.err.println(Strings.repeat("=", 100)); System.err.println("::::::Failed Tests for Suite ::: [" + name + "] ::: Test name [" + ctx.getName() + "]::::::"); System.err.println(Strings.repeat("=", 100)); failedTests.getAllResults().forEach(FailedInformationOnConsoleReporter::generateReport); System.err.println(Strings.repeat("=", 100)); System.err.println("\n\n"); } }
private void generateTests(String tagClass, IResultMap tests, ITestContext context, XMLStringBuffer xsb) { if (tests.getAllMethods().isEmpty()) return;
/** * @param tests * * @return */ protected Collection<ITestNGMethod> getMethodSet(final IResultMap tests) { final Set<ITestNGMethod> r = new TreeSet<ITestNGMethod>(new TestMethodSorter<ITestNGMethod>()); r.addAll(tests.getAllMethods()); return r; }
private String findTestResult(String methodName) { Iterator<ITestNGMethod> passed = passedTests.getAllMethods().iterator(); while(passed.hasNext()){ ITestNGMethod method = passed.next(); if(method.getMethodName().equals(methodName)){ return PASS; } } Iterator<ITestNGMethod> skipped = skippedTests.getAllMethods().iterator(); while(skipped.hasNext()){ ITestNGMethod method = skipped.next(); if(method.getMethodName().equals(methodName)){ return SKIP; } } Iterator<ITestNGMethod> failed = failedTests.getAllMethods().iterator(); while(failed.hasNext()){ ITestNGMethod method = failed.next(); if(method.getMethodName().equals(methodName)){ return FAIL; } } return null; }
private String findTestResult(String methodName) { Iterator<ITestNGMethod> passed = passedTests.getAllMethods().iterator(); while(passed.hasNext()){ ITestNGMethod method = passed.next(); if(method.getMethodName().equals(methodName)){ return PASS; } } Iterator<ITestNGMethod> skipped = skippedTests.getAllMethods().iterator(); while(skipped.hasNext()){ ITestNGMethod method = skipped.next(); if(method.getMethodName().equals(methodName)){ return SKIP; } } Iterator<ITestNGMethod> failed = failedTests.getAllMethods().iterator(); while(failed.hasNext()){ ITestNGMethod method = failed.next(); if(method.getMethodName().equals(methodName)){ return FAIL; } } return null; }
if (result.getTestContext().getPassedTests().getAllMethods().contains(result.getMethod())) { result.getTestContext().getPassedTests().removeResult(result); result.getTestContext().getFailedTests().addResult(result, result.getMethod());