Skip to content

Instantly share code, notes, and snippets.

@vinsguru
Created July 2, 2017 04:19
Show Gist options
  • Save vinsguru/56f29cf4bd5bb801c8e1f481825c7f05 to your computer and use it in GitHub Desktop.
Save vinsguru/56f29cf4bd5bb801c8e1f481825c7f05 to your computer and use it in GitHub Desktop.
public class XLSReader {
private final Fillo fillo;
private final String filePath;
private Connection connection;
public XLSReader(String filePath) {
fillo = new Fillo();
this.filePath = filePath;
}
public void getTests(String query) {
try {
connection = fillo.getConnection(this.filePath);
Recordset recordset = connection.executeQuery(query);
this.createSuite(recordset);
} catch (FilloException e) {
e.printStackTrace();
} finally {
connection.close();
}
}
private void createSuite(Recordset recordset) {
XmlMapper xmlMapper = new XmlMapper();
Suite suite = new Suite("TesTautomationGuru");
try {
while (recordset.next()) {
String testName = recordset.getField("TestCaseDescription");
String className = recordset.getField("ClassName");
String param = "Data";
String paramValue = recordset.getField("Data");
suite.addTest(testName, param, paramValue, className);
}
xmlMapper.writeValue(new File("c:/testng-suite.xml"), suite);
} catch (Exception e) {
e.printStackTrace();
} finally {
recordset.close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment