Eclipse Code Templates for TestNG DataProviders

Printer-friendly versionPrinter-friendly version

If you use Eclipse & TestNG you might be interested in these two simple code templates that will help you to create DataProviders.

I use Eclipse, I use TestNG and I like very much DataProviders.

Below I publish two code templates for Eclipse, that let me create tests with DataProviders in no time.

name: dataProvider

@DataProvider(name = "${dataProviderName}")
public Object[][] ${dataProviderMethodName}() {
return new Object[][] { ${cursor} };
}

name: dataProviderTest

@Test(dataProvider = "${dataProviderName}")
public void ${testMethodName}(${cursor}) {
}
No votes yet

Note that the latest Eclipse

Note that the latest Eclipse plug-in has a "New file" wizard that can create a @DataProvider example for you...

--
Cedric

thanks, but I prefer the code templates

Hello Cedric,

I tried to follow your advice, but it is way too much clicking for me. And I rather create @DataProviders when I already have a test class, so the wizard is not an option here.

I will stay with code template, but it is always good to know other options.

--
Tomek