org.testng.ISuite Java Examples

The following examples show how to use org.testng.ISuite. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtentIReporterSuiteClassListenerAdapter.java    From extentreports-testng-adapter with Apache License 2.0 7 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
    ExtentService.getInstance().setReportUsesManualConfiguration(true);
    ExtentService.getInstance().setAnalysisStrategy(AnalysisStrategy.SUITE);

    for (ISuite suite : suites) {
        Map<String, ISuiteResult> result = suite.getResults();

        for (ISuiteResult r : result.values()) {
            ITestContext context = r.getTestContext();

            ExtentTest suiteTest = ExtentService.getInstance().createTest(r.getTestContext().getSuite().getName());
            buildTestNodes(suiteTest, context.getFailedTests(), Status.FAIL);
            buildTestNodes(suiteTest, context.getSkippedTests(), Status.SKIP);
            buildTestNodes(suiteTest, context.getPassedTests(), Status.PASS);
        }
    }

    for (String s : Reporter.getOutput()) {
        ExtentService.getInstance().setTestRunnerOutput(s);
    }

    ExtentService.getInstance().flush();
}
 
Example #2
Source File: RemoteDifidoReporter.java    From difido-reports with Apache License 2.0 6 votes vote down vote up
/**
 * Event for end of suite
 * 
 * @param suite
 */
@Override
public void onFinish(ISuite suite) {
	// TODO: Find a place to call it.

	// We are not using shared execution, that means that we are the only
	// one that are using it and we just ended with it, so let's set it to
	// not active
	if (executionId > 0 && !difidoConfig.getPropertyAsBoolean(RemoteDifidoOptions.USE_SHARED_EXECUTION)) {
		try {
			client.endExecution(executionId);
		} catch (Exception e) {
			System.out.println("Failed to close execution with id " + executionId);
		}
		executionId = -1;
	}

}
 
Example #3
Source File: RemoteDifidoReporter.java    From difido-reports with Apache License 2.0 6 votes vote down vote up
public void onStart(ISuite suite) {
	super.onStart(suite);
	difidoConfig = new RemoteDifidoConfig();
	String host = null;
	int port = 0;
	try {
		enabled = Boolean.parseBoolean(difidoConfig.getPropertyAsString(RemoteDifidoOptions.ENABLED));
		if (!enabled) {
			return;
		}
		host = difidoConfig.getPropertyAsString(RemoteDifidoOptions.HOST);
		port = Integer.parseInt(difidoConfig.getPropertyAsString(RemoteDifidoOptions.PORT));
		client = new DifidoClient(host, port);
		executionId = prepareExecution();
		machineId = client.addMachine(executionId, getExecution().getLastMachine());
		enabled = true;
		log.fine(RemoteDifidoReporter.class.getName() + " was initialized successfully");
	} catch (Throwable t) {
		enabled = false;
		log.warning("Failed to init " + RemoteDifidoReporter.class.getName() + "connection with host '" + host + ":"
				+ port + "' due to " + t.getMessage());
	}

}
 
Example #4
Source File: AtsReportListener.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
@Override
public void generateReport(
                            List<XmlSuite> arg0,
                            List<ISuite> arg1,
                            String arg2 ) {

    //we just need the report format, that why we set other fields null
    ReportFormatter reportFormatter = new ReportFormatter(ReportAppender.getRuns(),
                                                          mailSubjectFormat,
                                                          null,
                                                          null,
                                                          0,
                                                          null);
    // send report by mail
    MailReportSender mailReportSender = new MailReportSender(reportFormatter.getDescription(),
                                                             reportFormatter.toHtml());
    mailReportSender.send();

}
 
Example #5
Source File: AtsTestngListener.java    From ats-framework with Apache License 2.0 6 votes vote down vote up
@Override
public void onFinish( ISuite suite ) {

    if (IS_TRACE_ENABLED) {
        ATS_LOGGER.log(this.hashCode() + ": End run event received", new Exception("Debugging trace"));
    }

    if (!ActiveDbAppender.isAttached) {
        return;
    }

    if (currentSuiteName != null) {

        endSuite();
    }

    // end the run
    logger.endRun();

}
 
Example #6
Source File: PowerEmailableReporter.java    From WebAndAppUITesting with GNU General Public License v3.0 6 votes vote down vote up
/** Creates a section showing known results for each method */
protected void generateMethodDetailReport(List<ISuite> suites) {
	for (ISuite suite : suites) {
		Map<String, ISuiteResult> r = suite.getResults();
		for (ISuiteResult r2 : r.values()) {
			ITestContext testContext = r2.getTestContext();
			if (r.values().size() > 0) {
				m_out.println("<h1>" + testContext.getName() + "</h1>");
			}
			resultDetail(testContext.getFailedConfigurations());
			resultDetail(testContext.getFailedTests());
			resultDetail(testContext.getSkippedConfigurations());
			resultDetail(testContext.getSkippedTests());
			resultDetail(testContext.getPassedTests());
		}
	}
}
 
Example #7
Source File: CarinaListener.java    From carina with Apache License 2.0 6 votes vote down vote up
protected void onHealthCheck(ISuite suite) {
    String healthCheckClass = Configuration.get(Parameter.HEALTH_CHECK_CLASS);
    if (suite.getParameter(Parameter.HEALTH_CHECK_CLASS.getKey()) != null) {
        // redefine by suite arguments as they have higher priority
        healthCheckClass = suite.getParameter(Parameter.HEALTH_CHECK_CLASS.getKey());
    }

    String healthCheckMethods = Configuration.get(Parameter.HEALTH_CHECK_METHODS);
    if (suite.getParameter(Parameter.HEALTH_CHECK_METHODS.getKey()) != null) {
        // redefine by suite arguments as they have higher priority
        healthCheckMethods = suite.getParameter(Parameter.HEALTH_CHECK_METHODS.getKey());
    }

    String[] healthCheckMethodsArray = null;
    if (!healthCheckMethods.isEmpty()) {
        healthCheckMethodsArray = healthCheckMethods.split(",");
    }
    checkHealth(suite, healthCheckClass, healthCheckMethodsArray);
}
 
Example #8
Source File: ExtentIReporterSuiteListenerAdapter.java    From extentreports-testng-adapter with Apache License 2.0 6 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
    ExtentService.getInstance().setReportUsesManualConfiguration(true);
    ExtentService.getInstance().setAnalysisStrategy(AnalysisStrategy.SUITE);

    for (ISuite suite : suites) {
        Map<String, ISuiteResult> result = suite.getResults();

        for (ISuiteResult r : result.values()) {
            ITestContext context = r.getTestContext();

            ExtentTest suiteTest = ExtentService.getInstance().createTest(r.getTestContext().getSuite().getName());
            buildTestNodes(suiteTest, context.getFailedTests(), Status.FAIL);
            buildTestNodes(suiteTest, context.getSkippedTests(), Status.SKIP);
            buildTestNodes(suiteTest, context.getPassedTests(), Status.PASS);
        }
    }

    for (String s : Reporter.getOutput()) {
        ExtentService.getInstance().setTestRunnerOutput(s);
    }

    ExtentService.getInstance().flush();
}
 
Example #9
Source File: AppiumParallelMethodTestListener.java    From AppiumTestDistribution with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onStart(ISuite iSuite) {
    try {
        appiumServerManager.startAppiumServer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #10
Source File: LogLevelChangeListener.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
@Override
public void onStart(ISuite iSuite) {
    String logLevel = iSuite.getParameter(LOG_LEVEL_PARAM_NAME);
    if (StringUtils.isNotEmpty(logLevel)) {
        LogUtil.configureLogLevel(logLevel);
    }
}
 
Example #11
Source File: TestReport.java    From PatatiumWebUi with Apache License 2.0 5 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory)
{
	List<ITestResult> list = new ArrayList<ITestResult>();
	for (ISuite suite : suites) {
		Map<String, ISuiteResult> suiteResults = suite.getResults();
		for (ISuiteResult suiteResult : suiteResults.values()) {
			ITestContext testContext = suiteResult.getTestContext();
			IResultMap passedTests = testContext.getPassedTests();
			IResultMap failedTests = testContext.getFailedTests();
			IResultMap skippedTests = testContext.getSkippedTests();
			IResultMap failedConfig = testContext.getFailedConfigurations();
			list.addAll(this.listTestResult(passedTests));
			list.addAll(this.listTestResult(failedTests));
			list.addAll(this.listTestResult(skippedTests));
			//list.addAll(this.listTestResult(failedConfig));
		}
	}
	CopyReportResources reportReource=new CopyReportResources();

	try {
		reportReource.copyResources();
	} catch (Exception e) {
		// TODO: handle exception
		e.printStackTrace();
	}
	this.sort(list);
	this.outputResult(list, outputDirectory+"/report.html");


}
 
Example #12
Source File: CucumberReport.java    From SeleniumCucumber with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onFinish(ISuite suite) {
	try {
		
		File jsonfile = new File("target/");
		File reportOutputDirectory = new File("target/test-classes/reports/cucumberreports/");
		
		String[] fileNames = jsonfile.list(new FilenameFilter() {
			
			@Override
			public boolean accept(File dir, String name) {
				if(name.endsWith(".json"))
					return true;
				return false;
			}
		});
		
		for (int i = 0; i < fileNames.length; i++) {
			fileNames[i] = jsonfile.getAbsolutePath() + "/" + fileNames[i];
		}
		
		List<String> jsonFiles = Arrays.asList(fileNames);

		Configuration configuration = new Configuration(reportOutputDirectory, suite.getName());
		configuration.setStatusFlags(true, true, true);

		ReportBuilder reportBuilder = new ReportBuilder(jsonFiles, configuration);
		reportBuilder.generateReports();
		oLog.info("Report Generated : " + configuration.getReportDirectory());

	} catch (Exception e) {
		oLog.equals(e);
	}
}
 
Example #13
Source File: TestRunnerFactory.java    From qaf with MIT License 5 votes vote down vote up
@Override
public TestRunner newTestRunner(ISuite suite, XmlTest test, Collection<IInvokedMethodListener> listeners,
		List<IClassListener> classListeners) {
	TestRunner runner = null!=testRunnerFactory?testRunnerFactory.newTestRunner(suite, test, listeners, classListeners):
              new TestRunner(configuration, suite, test,
	                  false /*skipFailedInvocationCounts */,
	                  listeners,classListeners);;
	init(runner);
	return runner;
}
 
Example #14
Source File: QAFTestNGListener2.java    From qaf with MIT License 5 votes vote down vote up
@Override
public void onStart(final ISuite suite) {
	if (skipReporting())
		return;
	super.onStart(suite);
	ReporterUtil.createMetaInfo(suite);
}
 
Example #15
Source File: AllureTestNg.java    From allure-java with Apache License 2.0 5 votes vote down vote up
private void ifSuiteFixtureStarted(final ISuite suite, final ITestNGMethod testMethod) {
    if (testMethod.isBeforeSuiteConfiguration()) {
        startBefore(getUniqueUuid(suite), testMethod);
    }
    if (testMethod.isAfterSuiteConfiguration()) {
        startAfter(getUniqueUuid(suite), testMethod);
    }
}
 
Example #16
Source File: SeleniumTestHandler.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void onStart(ISuite suite) {
  suite.setParentInjector(injector);
  long numberOfEnabledTests =
      suite.getAllMethods().parallelStream().filter(ITestNGMethod::getEnabled).count();
  LOG.info("Starting suite '{}' with {} test methods.", suite.getName(), numberOfEnabledTests);
}
 
Example #17
Source File: CucumberListener.java    From AppiumTestDistribution with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onStart(ISuite iSuite) {
    try {
        appiumServerManager.startAppiumServer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #18
Source File: CucumberListener.java    From AppiumTestDistribution with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onFinish(ISuite iSuite) {
    try {
        appiumServerManager.stopAppiumServer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #19
Source File: AppiumParallelTestListener.java    From AppiumTestDistribution with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onStart(ISuite iSuite) {
    try {
        appiumServerManager.startAppiumServer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #20
Source File: CustomAutomationReport.java    From pxf with Apache License 2.0 5 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {

	StringBuilder sBuilder = new StringBuilder();

	// Iterating over each suite
	for (ISuite suite : suites) {

		// Getting the results for the each suite
		Map<String, ISuiteResult> suiteResults = suite.getResults();
		for (ISuiteResult sr : suiteResults.values()) {
			// get context for result
			ITestContext tc = sr.getTestContext();
			// go over all cases
			for (ITestNGMethod method : tc.getAllTestMethods()) {
				// if a case has "ExpectedFaiGPDBWritable.javalure" annotation, insert to sBuilder

				if (method.getConstructorOrMethod().getMethod().getAnnotation(ExpectedFailure.class) != null) {
					sBuilder.append(method.getInstance().getClass().getName() + "/" + method.getMethodName()).append(System.lineSeparator());
				}
			}
		}
	}

	// write results to file
	try {
		FileUtils.writeStringToFile(new File(outputDirectory + "/automation_expected_failures.txt"), sBuilder.toString(), false);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
Example #21
Source File: VerifyEarlReporter.java    From teamengine with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpClass() throws Exception {
    testContext = mock(ITestContext.class);
    suite = mock(ISuite.class);
    when(suite.getName()).thenReturn("abc20-1.0");
    when(testContext.getSuite()).thenReturn(suite);
    xmlSuite = mock(XmlSuite.class);
    when(suite.getXmlSuite()).thenReturn(xmlSuite);
}
 
Example #22
Source File: AbstractDifidoReporter.java    From difido-reports with Apache License 2.0 5 votes vote down vote up
/**
 * Event for start of suite
 * 
 * @param suite
 */
@Override
public void onStart(ISuite suite) {
	execution = null;
	totalPlannedTests = getAllPlannedTestsCount(suite);
	updateIndex();
	generateUid();

	addMachineToExecution(suite.getHost());
}
 
Example #23
Source File: AbstractDifidoReporter.java    From difido-reports with Apache License 2.0 5 votes vote down vote up
private int getAllPlannedTestsCount(ISuite suite) {
	int totalPlanned = 0;

	for (ITestNGMethod method : suite.getAllMethods()) {
		totalPlanned += getDataProviderCases(method);
	}
	return totalPlanned;

}
 
Example #24
Source File: AppiumParallelTestListener.java    From AppiumTestDistribution with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onFinish(ISuite iSuite) {
    try {
        appiumServerManager.stopAppiumServer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #25
Source File: FilterTestsListener.java    From carina with Apache License 2.0 5 votes vote down vote up
@Override
public void onStart(ISuite suite) {
    rules = parseRules(Configuration.get(Configuration.Parameter.TEST_RUN_RULES));

    // rules are absent
    if (rules.isEmpty()) {
        LOGGER.info("There are no any rules and limitations");
        return;
    }

    boolean isPerform;
    LOGGER.info("Extracted rules: ".concat(rules.toString()));
    for (ITestNGMethod testMethod : suite.getAllMethods()) {
        isPerform = true;
        // multiple conditions
        for (Rule rule : rules) {
            // condition when test doesn't satisfy at least one filter
            if (!isPerform) {
                break;
            }
            isPerform = rule.getTestFilter().isPerform(testMethod, rule.getRuleValues());
        }
        // condition when test should be disabled
        if (!isPerform) {
            disableTest(testMethod);
        }
    }
}
 
Example #26
Source File: ReportManagerHook.java    From difido-reports with Apache License 2.0 5 votes vote down vote up
@Override
public void onStart(ISuite suite) {
	if (0 != numOfSuites++) {
		return;
	}
	ReportManager.getInstance().onStart(suite);

}
 
Example #27
Source File: ReportManagerHook.java    From difido-reports with Apache License 2.0 5 votes vote down vote up
@Override
public void onFinish(ISuite suite) {
	if (0 != --numOfSuites) {
		return;
	}
	ReportManager.getInstance().onFinish(suite);

}
 
Example #28
Source File: CustomHTMLReporter.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectoryName) {
    try {
        super.generateReport(xmlSuites, suites, outputDirectoryName);
        boolean onlyFailures = "true".equals(System.getProperty(ONLY_FAILURES_PROPERTY, "false"));
        File outputDirectory = new File(outputDirectoryName, REPORT_DIRECTORY);
        createCustomResults(suites, outputDirectory, onlyFailures);
    } catch (Exception ex) {
        throw new ReportNGException("Failed generating HTML report.", ex);
    }

}
 
Example #29
Source File: ZafiraConfigurator.java    From carina with Apache License 2.0 5 votes vote down vote up
@Override
public String getOwner(SuiteAdapter suiteAdapter) {
    ISuite suite = (ISuite) suiteAdapter.getSuite();
    String owner = suite.getParameter("suiteOwner");
    LOGGER.debug("owner: " + owner);
    return owner != null ? owner : "";
}
 
Example #30
Source File: CustomHTMLReporter.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private void createCustomResults(List<ISuite> suites, File outputDirectory,
        boolean onlyShowFailures) {
    AtomicInteger suiteIndex = new AtomicInteger(1);
    suites.stream().forEach(suite -> {
        AtomicInteger testIndex = new AtomicInteger(1);
        Consumer<ISuiteResult> resultConsumer = getSuiteResultConsumer(outputDirectory, onlyShowFailures,
                suiteIndex, testIndex);
        suite.getResults().values().stream().forEach(resultConsumer);
        suiteIndex.incrementAndGet();
    });
}