Search in sources :

Example 1 with Report

use of net.sf.sahi.ant.Report in project sakuli by ConSol.

the class SahiConnector method startSahiTestSuite.

/**
     * starts a specific sahi test suite in sakuli
     */
public void startSahiTestSuite() throws SakuliInitException {
    logger.info("Start Sakuli-Test-Suite from folder \"" + testSuite.getTestSuiteFolder().toAbsolutePath().toString() + "\"");
    checkTestSuiteFile();
    //        ConnectionTester.checkTestCaseInitURL(testSuite);
    //default sahi runner to play the sahi script
    TestRunner runner = getTestRunner();
    runner.setIsSingleSession(false);
    //config reporter
    runner.addReport(new Report("html", sakuliProperties.getLogFolder().toAbsolutePath().toString()));
    //add include folder property
    runner.setInitJS(getInitJSString());
    try {
        //is there to handle exceptions in the catch block from this.reconnect()
        try {
            countConnections++;
            // Script-Runner starts
            logger.info("Sahi-Script-Runner starts!\n");
            //starts the script runner with the prefilled configurations
            String output = runner.execute();
            testSuite.setStopDate(new Date());
            logger.info("test suite '" + testSuite.getId() + "' stopped at " + TestSuite.GUID_DATE_FORMATE.format(testSuite.getStopDate()));
            logger.info("Sahi-Script-Runner executed with " + output);
            //should only thrown if an exception could fetched by the backend of some reason
            if (output.equals("FAILURE")) {
                if (isSahiScriptTimout(testSuite.getException())) {
                    logger.warn("Sahi-Script-Runner timeout detected, start retry!");
                    SakuliException causingError = new SakuliException(testSuite.getException());
                    //reset all values
                    InitializingServiceHelper.invokeInitializingServcies();
                    this.reconnect(causingError);
                } else if (testSuite.getException() == null) {
                    throw new SakuliInitException("SAHI-Proxy returned 'FAILURE' ");
                }
            }
        } catch (ConnectException | IllegalMonitorStateException e) {
            //Reconnect - wait for Thread "sahiRunner"
            this.reconnect(e);
        }
    } catch (Throwable e) {
        sakuliExceptionHandler.handleException(e);
    } finally {
        logger.info("test suite finished");
        //shutdown sahi proxy!
        sahiProxy.shutdown();
    }
}
Also used : Report(net.sf.sahi.ant.Report) SakuliInitException(org.sakuli.exceptions.SakuliInitException) TestRunner(net.sf.sahi.test.TestRunner) SakuliException(org.sakuli.exceptions.SakuliException) Date(java.util.Date) ConnectException(java.net.ConnectException)

Aggregations

ConnectException (java.net.ConnectException)1 Date (java.util.Date)1 Report (net.sf.sahi.ant.Report)1 TestRunner (net.sf.sahi.test.TestRunner)1 SakuliException (org.sakuli.exceptions.SakuliException)1 SakuliInitException (org.sakuli.exceptions.SakuliInitException)1