Search in sources :

Example 16 with TestNG

use of org.testng.TestNG 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)

Example 17 with TestNG

use of org.testng.TestNG in project OpenAM by OpenRock.

the class TestHarness method execute.

public void execute(HttpServletResponse res, String tests) {
    List<String> classes = getTestClasses(tests);
    List<Class> javaClasses = new ArrayList<Class>();
    try {
        for (String strClass : classes) {
            if (strClass.endsWith(".jsp")) {
                executeJSP(strClass);
            } else {
                javaClasses.add(Class.forName(strClass));
            }
        }
    } catch (ClassNotFoundException e) {
        UnittestLog.logError("TestHarness.execute", e);
    }
    if (!javaClasses.isEmpty()) {
        Class[] testngClasses = new Class[javaClasses.size()];
        int i = 0;
        for (Class c : javaClasses) {
            testngClasses[i++] = c;
        }
        try {
            TestNG testng = new TestNG();
            testng.addListener(new TestListener());
            testng.setTestClasses(testngClasses);
            testng.run();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    UnittestLog.logMessage("TestHarness:DONE");
}
Also used : TestNG(org.testng.TestNG) ArrayList(java.util.ArrayList) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 18 with TestNG

use of org.testng.TestNG in project incubator-atlas by apache.

the class SecureEmbeddedServerTestBase method runOtherSuitesAgainstSecureServer.

/**
     * Runs the existing webapp test cases, this time against the initiated secure server instance.
     * @throws Exception
     */
@Test
public void runOtherSuitesAgainstSecureServer() throws Exception {
    final PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CERT_STORES_CREDENTIAL_PROVIDER_PATH, providerUrl);
    // setup the credential provider
    setupCredentials();
    try {
        secureEmbeddedServer = new SecureEmbeddedServer(securePort, TestUtils.getWarPath()) {

            @Override
            protected PropertiesConfiguration getConfiguration() {
                return configuration;
            }
        };
        secureEmbeddedServer.server.start();
        TestListenerAdapter tla = new TestListenerAdapter();
        TestNG testng = new TestNG();
        testng.setTestClasses(new Class[] { AdminJerseyResourceIT.class, EntityJerseyResourceIT.class, MetadataDiscoveryJerseyResourceIT.class, TypesJerseyResourceIT.class });
        testng.addListener(tla);
        testng.run();
    } finally {
        secureEmbeddedServer.server.stop();
    }
}
Also used : TestNG(org.testng.TestNG) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) TestListenerAdapter(org.testng.TestListenerAdapter) Test(org.testng.annotations.Test)

Aggregations

TestNG (org.testng.TestNG)18 Test (org.testng.annotations.Test)5 TrackingTestNGTestListener (org.springframework.test.context.testng.TrackingTestNGTestListener)2 TestListenerAdapter (org.testng.TestListenerAdapter)2 BeforeClass (org.testng.annotations.BeforeClass)2 IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 MalformedURLException (java.net.MalformedURLException)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)1 GradleException (org.gradle.api.GradleException)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 ITestListener (org.testng.ITestListener)1 SimpleBaseTest (samples.testng.SimpleBaseTest)1