# How can I execute selected test cases from list of testcases in TestNG at runtime?

I want to create a page with the details of test cases (say a HTML Page with some content). Say the testcases will be listed there. When i want to run the test cases then I will select them and click on 'RUN' so it will integrate with the testng.xml file and the run will happen.

Any ideas for implementing this? Or is there any framework available on the internet which has already implemented this scenario?

• Where will you select the test cases? Why do you need this? You could write some code to insert XML nodes in the testng.xml... – FDM Mar 4 '16 at 12:27
• After i automated some test cases say 40 testcases , i thought like if i have to execute 2-3 testcases from the above how can i achieve.if i'd have a UI which allows me to select and deselect the testcases names and then execute then this will be wonderful right ???? – Ram Patro Mar 4 '16 at 12:35

I have set up a similar utility using JUnit test cases.

My framework used Groovy/Spock with listeners that reported results into a Couchbase DB. From there the tests were displayed on an AngularJS site which had the options to run either the selected test or run all test cases.

I have posted the API portion of the code here which should not be overly difficult to convert from JUnit to TestNG.

If a test method is annotated with @Test(enabled = false), then the test case that is not ready to test is bypassed.

I had developed one web application test suite which had used similar execution flow but had little different way. I had all the test suite/cases in excel sheet and for each test suite/case, I kept one suiteToRun/caseToRun flag. In the code I was checking if the suiteToRun/caseToRun is set to Yes, continue the execution or skip if it is set to No

I hope this will give you some better way to perform execution.

In eclipse you can select the particular amount of test cases you want to run.

It comes as a explorer on the left side enabling you to select the particular test case you wish to run using Test NG In the Image below, I have 2 test cases 1. Logout 2. Test1 , I can rightclick and run the one I wish to execute and get its report.