Monday 9 December 2013

TestNG Execution Report


TestNG ExecutionReport
we are 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.



No comments:

Post a Comment