Created
May 4, 2011 00:38
-
-
Save jweden/954540 to your computer and use it in GitHub Desktop.
Superclass for tests that calls into the groovy class to obtain data for the data-driven tests
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
package weden.jason.qa.someProduct; | |
import java.util.List; | |
import java.util.Map; | |
import org.apache.log4j.LogManager; | |
import org.apache.log4j.Logger; | |
import org.testng.annotations.DataProvider; | |
/** | |
* | |
* Base class for TestNG test classes. Has support for data-driven tests using TestNG data provider. | |
* | |
*/ | |
public class TestBase { | |
private static final Logger LOG = LogManager.getLogger(TestBase.class); | |
@DataProvider(name = "queries") | |
public Object[][] obtainTestCasesDataProvider() { | |
final List<Map<String, String>> testCases = new TestcaseGrabber().getTestcases(); | |
final Object[][] dataProvider = new Object[testCases.size()][2]; | |
int outerArrayIndex = 0; | |
for (final Map<String, String> testCase : testCases) { | |
final Object[] innerArray = new Object[2]; | |
LOG.info(testCase.get("testDescription")); | |
innerArray[0] = testCase.get("testDescription"); | |
innerArray[1] = testCase.get("xmlToUse"); | |
dataProvider[outerArrayIndex] = innerArray; | |
outerArrayIndex++; | |
} | |
return dataProvider; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment