Page 1 of 1

How to disable child test cases?

Posted: Tue Feb 24, 2015 8:58 pm
by nmathew
Can someone help me out here on how to disable all the child test cases in a test suite using code module?
I'm using the following code snippet currently to disable test cases in a suite

Code: Select all

TestSuite.Current.GetTestCase("TestCase1").Checked = false;
TestSuite.Current.GetTestCase("TestCase2").Checked = false;
TestSuite.Current.GetTestCase("TestCase13").Checked = false;
...
...

But I would like to know if I can do this in one line of code or more of an iterative way of looking each child test case of the current test suite and marking it as unchecked so that I don't need to worry about test executing any new test case that someone added under the suite

Thanks in advance for your help

Re: How to disable child test cases?

Posted: Wed Feb 25, 2015 6:30 pm
by Support Team
Hi nmathew,

You could do it with the following code but please be aware that undocumented code is used and that we reserve the right to change it at any time without notification:
var testSuite = (TestSuite)TestSuite.Current;
			
			var entries = testSuite.GetAllTestSuiteEntries();
			
			foreach(var tc in entries){
				
				if(tc.GetType().ToString().Equals("Ranorex.Core.Testing.TestCase")){
					Report.Info(tc.Name);
					var testCase = (TestCase)tc;
					testCase.Checked = false;
				}
				
			}
Regards,
Markus

Re: How to disable child test cases?

Posted: Thu Feb 26, 2015 3:43 pm
by nmathew
That worked. Thank you Markus!!