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();
}
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");
}
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();
}
}
Aggregations