How to get the list of test cases in a test suite

Class library usage, coding and language questions.
vatsal
Posts: 1
Joined: Tue Jul 01, 2014 6:23 am

How to get the list of test cases in a test suite

Post by vatsal » Tue Jul 01, 2014 6:29 am

We are trying to enable/disable testcases in a test suite dynamically just before starting the execution. Planning to use

Code: Select all

TestSuite.Current.GetTestCase("TESTCASE_NAME").Checked= true/false 
What is the best way to get the list of testcases from the test suite using ranorex APIs so that we can iterate through it to enable/disable the test cases.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to get the list of test cases in a test suite

Post by Support Team » Wed Jul 02, 2014 4:47 pm

Hi,

Would the following forum thread be of help for you: Starting Testcase by condition?

Do you know that you can also specify different so called Run Configurations?
This allows you to specify and then select different testcase configurations. You can also select a specific testcase configuration by using the command line argument described here Running Tests without Ranorex Studio:
runconfig|rc:<configuration name>

Runs the test cases of the specified configuration defined by the rxtst file. Configurations can be edited using Ranorex Studio or TestSuiteRunner. By default, the currently selected run config is used.
Please let me know when you need further assistance!

Regards,
Markus
.
Image

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: How to get the list of test cases in a test suite

Post by mzperix » Mon Jul 07, 2014 10:30 am

Hi vatsal,

I looked into the Ranorex API, and found that the TestSuiteRunConfig Class holds the test cases name in a sorted list (TestSuiteRunConfig.TestCases)
see documentaion: http://www.ranorex.com/Documentation/Ra ... Config.htm

Hope this helps,
Zoltan

BorisS
Posts: 11
Joined: Fri Jul 11, 2014 2:25 pm

Re: How to get the list of test cases in a test suite

Post by BorisS » Tue Sep 09, 2014 9:11 am

TestCases hold only guid strings not the class themselves. To get the active test cases I used the following code

Code: Select all

 List<string> tcases = new List<string>();		//all testcases in this testsuite
int i = 0;
			
var rconf = TestSuite.Current.SelectedRunConfig.GetActiveTestCases();
			
for (i =0; i< rconf.Count; i++)
	tcases.Add(cname);
	
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			
foreach (Type tp in types)
{				
     if( tcases.Contains(tp.Name) ) 
     {
                //'tp' it is a test case 
     }
}