*
* @param filenames Selenese script filenames.
* @return result.
*/
public Result run(String... filenames) {
Result totalResult = UNEXECUTED;
List<TestSuite> testSuiteList = new ArrayList<TestSuite>();
for (String filename : filenames) {
Selenese selenese = Parser.parse(filename, commandFactory);
Parser.setContextForBackwardCompatibility(selenese, this);
if (selenese.isError()) {
log.error(selenese.toString());
totalResult = ((ErrorSource) selenese).getResult();
continue;
}
switch (selenese.getType()) {
case TEST_SUITE:
testSuiteList.add((TestSuite) selenese);
break;
case TEST_CASE:
TestSuite testSuite = Binder.newTestSuite(filename, selenese.getName());
testSuite.addSelenese(selenese);
testSuiteList.add(testSuite);
break;
}
}
if (totalResult != UNEXECUTED)
return totalResult;
for (TestSuite testSuite : testSuiteList) {
Result result;
try {
result = execute(testSuite);
} catch (RuntimeException e) {
log.error(e.getMessage());
throw e;