Created
July 2, 2017 04:19
-
-
Save vinsguru/56f29cf4bd5bb801c8e1f481825c7f05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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