Closed ceazy79 closed 8 years ago
Fixed it and you should be able to use it like this:
public class DataProviderTest extends TestNGCitrusTest {
private static final Logger log = LoggerFactory.getLogger(DataProviderTest.class);
@DataProvider(name = "getTestData")
public Object[][] getTestData() {
String[][] result = new String[][] { { "hello", null } };
return result;
}
@Test(testName = "dataProviderAndCitrusResourceInjectionTest",
enabled = true,
dataProvider = "getTestData")
@CitrusTest(name = "dataProviderAndCitrusResourceInjectionTest")
@Parameters({"dataRecord", "runner" })
public void dataProviderAndCitrusResource(String dataRecord, @CitrusResource TestRunner runner) throws Exception {
runner.echo("Hello Citrus Test World.");
log.info("DataProvider dataRecord = " + dataRecord);
}
}
Scenario:
Trying to use TestNG DataProvider together with TestRunner resource injection in order to use the runner in a thread-safe way.
Testcase:
`public class DataProviderTest extends TestNGCitrusTest {
} `
Expected result:
TestRunner executes echo action and log contains string "DataProvider dataRecord = hello"
Actual result:
org.testng.TestNGException: The data provider is trying to pass 1 parameters but the method de.finkonsens.geco.citrus.DataProviderTest#dataProviderAndCitrusResource takes 2 and TestNG is unable in inject a suitable object
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1 at org.testng.internal.Invoker.injectParameters(Invoker.java:1249) ... 21 more
Kind regards, Chris