myTestMethod(String someParam1, String someParam2, ITestContext
context)
What would be the best way to use both, dataProviders and parameter
injection at the same time?
All I can think is
Object[][] myDataProvider(ITestContext context) {
return new Object[][] {
{"val1, "val2, context},
{"val3, "val4, context},
}
but i find the solution quite ugly, is there a better way to do it?
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
@Test(dataProvider = "sampleProvider", groups="hostnames")
public void myTest(String arg1, String arg2, ITestContext context) {
assertEquals(arg1, arg2);
}
@DataProvider
public Object[][] sampleProvider() {
return new Object[][] {
{"a", "a"},
{"b", "b"},
};
}
FAILED: myTest(myTest: Wrong number of arguments were passed by the
Data Provider: found 2 but expected 3)
java.lang.IllegalArgumentException: wrong number of arguments
On Mar 2, 11:15 am, Cédric Beust ♔ <cbe...@google.com> wrote:
> Just declare the ITestContext parameter in your test method, TestNG will
> inject the right things...
>
> --
> ***Cédric
> *
>
> On Tue, Mar 2, 2010 at 11:13 AM, David Garcia <david.garcia...@gmail.com>wrote:
>
> > I have a test that gets parameters from a dataProvider, but I would
> > also like to pass the test context to my test method.
>
> > myTestMethod(String someParam1, String someParam2, ITestContext
> > context)
>
> > What would be the best way to use both, dataProviders and parameter
> > injection at the same time?
>
> > All I can think is
>
> > Object[][] myDataProvider(ITestContext context) {
> > return new Object[][] {
> > {"val1, "val2, context},
> > {"val3, "val4, context},
> > }
>
> > but i find the solution quite ugly, is there a better way to do it?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "testng-users" group.
> > To post to this group, send email to testng...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > testng-users...@googlegroups.com<testng-users%2Bunsu...@googlegroups.com>
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.