Search in sources :

Example 1 with ITestListener

use of org.testng.ITestListener in project ats-framework by Axway.

the class AtsTestngSuiteListener method onStart.

public void onStart(ISuite suite) {
    /*
         * Check whether we are using a patched TestNG distribution, 
         * in such case ATS supports inserting messages before a testcase is started and after it is ended.
        */
    ActiveDbAppender.isBeforeAndAfterMessagesLoggingSupported = Version.VERSION.contains("ATS");
    // get the run name specified by the user
    String runName = CommonConfigurator.getInstance().getRunName();
    if (runName.equals(CommonConfigurator.DEFAULT_RUN_NAME)) {
        // the user did not specify a run name, use the one from TestNG
        runName = suite.getName();
    }
    // the following is needed in case when more than one RUN are executed sequentially
    // we need to clear some temporary data in the other listener we use
    TestNG testNgInstance = TestNG.getDefault();
    // cleanup the class level listener
    new AtsTestngClassListener().resetTempData();
    // cleanup the test level listener
    for (ITestListener listener : testNgInstance.getTestListeners()) {
        if (listener instanceof AtsTestngTestListener) {
            ((AtsTestngTestListener) listener).resetTempData();
        }
    }
    // start a new run
    String hostNameIp = "";
    try {
        InetAddress addr = InetAddress.getLocalHost();
        hostNameIp = addr.getHostName() + "/" + addr.getHostAddress();
    } catch (UnknownHostException uhe) {
        hostNameIp = null;
    }
    logger.startRun(runName, CommonConfigurator.getInstance().getOsName(), CommonConfigurator.getInstance().getProductName(), CommonConfigurator.getInstance().getVersionName(), CommonConfigurator.getInstance().getBuildName(), hostNameIp);
    logSystemInformation();
    logClassPath();
}
Also used : UnknownHostException(java.net.UnknownHostException) TestNG(org.testng.TestNG) ITestListener(org.testng.ITestListener) InetAddress(java.net.InetAddress)

Aggregations

InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 ITestListener (org.testng.ITestListener)1 TestNG (org.testng.TestNG)1