setConnectionParameters((String) cmdLineArgs.get(TestNGCommandLineArgs.HOST_COMMAND_OPT),
Integer.parseInt((String) cmdLineArgs.get(TestNGCommandLineArgs.PORT_COMMAND_OPT)));
}
public void run() {
final StringMessageSenderHelper msh= new StringMessageSenderHelper(m_host, m_port);
try {
if(msh.connect()) {
if(m_suites.size() > 0) {
int testCount= 0;
for(int i= 0; i < m_suites.size(); i++) {
testCount+= ((XmlSuite) m_suites.get(i)).getTests().size();
}
GenericMessage gm= new GenericMessage(MessageHelper.GENERIC_SUITE_COUNT);
gm.addProperty("suiteCount", m_suites.size()).addProperty("testCount", testCount);
msh.sendMessage(gm);
addListener(new RemoteSuiteListener(msh));
setTestRunnerFactory(new DelegatingTestRunnerFactory(buildTestRunnerFactory(), msh));
super.run();
}
else {
System.err.println("WARNING: No test suite found. Nothing to run");
}
}
else {
System.err.println("Cannot connect to " + m_host + " on " + m_port);
}
}
catch(Throwable cause) {
cause.printStackTrace(System.err);
}
finally {
msh.shutDown();
System.exit(0);
}
}