Eclipse Code Templates for TestNG DataProviders

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}) {
}

Re:

Hello, thank you for the post and the templates, they helped me a lot. Just found some reference tips at http://www.tubesfan.com/watch/cobol-code-templates-in-eclipse on Code templates in Eclipse, thought maybe readers would find it practical and make use of it.

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

 
 
 
This used to be my blog. I moved to http://tomek.kaczanowscy.pl long time ago.

 
 
 

Please comment using