Search code examples
javatestngdataprovider

Is it possible to set an annotation in TestNG via testng.xml?


I am testing with the wonderful TestNG-Framework. My question is if it is possible to set the annotations for @Test-annotation in the testng.xml-configuration file? I don't want to hard-code the @Test-annotation like

@Test(dataProvider = "dataFileProvider", dataProviderClass = TestDataProvider.class)

I want to configure it in the testng.xml


Solution

  • I have got two ideas on this case:

    Workaraound 1: StaticProvider

    You can easily change the Static Provider if needed

    Workaraound 2: Annotation Transformer

    Never tried that but should work even if have to grab the XML- data manually

    Looking forward to Mr. Beust's answer... ;)