I am using @Factory annotation from TestNG to create tests dynamically. It will read a property file that contains the list of test cases to be executed and return them.
@Factory
public Object[] dp() throws IOException {
FileInputStream fs=new FileInputStream(System.getProperty("user.dir")+"/TestCaseNames.properties");
Properties p=new Properties();
p.load(fs);
Set<Object> myset=p.keySet();
System.out.println("myset " + myset);
Object[] str= new Object[myset.size()];
int cnt=0;
for (Object t : myset) {
str[cnt]=new Startup(p.getProperty((String) t));
cnt=cnt+1;
}
return str;
}
Now the Test method is as below:
@Parameters({ "browser", "url", "app"})
@Test
public void ExecuteTestCase(String bname, String uname, String appname)
throws
NumberFormatException, MongoException, BiffException,
IOException, WriteException
{
...
...
}
The test cases are executing fine but after execution the report is generating as below where it is showing the Test method name as 'ExecuteTestCase' instead of the original test method name present in the property file.
Please update me with the resolution so that the TestNG report file contains the proper method name instead of 'ExecuteTestCase'
ExecuteTestCase()is a method of Startup class, correct? Also, how can your Factory translate a method name from property file to real method in a class? What are parameters of Startup constructor? How does your parameters file looks like? How those method names are defined? – dzieciou Nov 1 '12 at 7:26