I try to run @Test method, but define @Test at class level with dataProvider attribute and also mention method as a @Test, please take look on below code for more idea
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@Test(dataProvider="Data")
public class TestAtClassLevel{
@Test
public void testCase(String value) {
System.out.println("Test case");
}
@DataProvider(name="Data")
public Object[][] dataProvider(){
String value[][]=new String[2][1];
value[0][0]="FirstValue";
value[1][0]="SecondValue";
return value;
}
}
I try to run the above code but I get the below exception:
[Utils] [ERROR] [Error] org.testng.TestNGException:
Cannot inject @Test annotated Method [testCase] with [class java.lang.String].
I am able to run the above code after remove @Test from method-level
Why am I getting an exception even if I declare data provider name at class level?