2

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'

3
  • 1
    It may help or speed up reading your question if you remove from your code irrelevant parts (e.g. exceptions) and add those that matter. For instance, 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
  • I would also recommend you to send your code to codereview.stackexchange.com site to get suggestions how to improve your code leggibility. I'd like to help you with your problem, but I got problem to see the context.
    – dzieciou
    Nov 1 '12 at 7:30
  • 1
    I'm voting to close this question as off-topic because it appears to be obsolete and is unlikely to be helpful for other users, and would be a better fit for codereview.stackexchange.com
    – c32hedge
    Sep 12 '17 at 14:56