Q:

How to run Junit / TestNG tests based on an external input?

I have an Excel file where I am storing the Test case Name / Id.
Now, If my Test case name(in excel) is starting with 'test' I want to execute one of my Junit / TestNG test . If my test case name(in excel) is starting with 'check', I want to execute another Junit / TestNG test. And similarly, I want to execute different tests based on Ids in the excel.
How would I be able to do this?
Can some one please post an example which can be of great help to me.
Thanks,
Mike

A:

I think what you want to do is dynamically build tests based on your excel sheet.
This is how you can run testng programmatically.
What you would need to do is read from your excel, create XmlClass and set the methods for xmlclass based on the testnames of your methods.  Add the xmlclass to XmlSuite.
So basically you are generating a dynamic suite at runtime based on the testcase names in your excel.

