How to disable child test cases?

Class library usage, coding and language questions.
nmathew
Certified Professional
Certified Professional
Posts: 8
Joined: Thu Nov 06, 2014 6:40 pm
Contact:

How to disable child test cases?

Post by nmathew » Tue Feb 24, 2015 8:58 pm

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

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

Re: How to disable child test cases?

Post by Support Team » Wed Feb 25, 2015 6:30 pm

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
.
Image

nmathew
Certified Professional
Certified Professional
Posts: 8
Joined: Thu Nov 06, 2014 6:40 pm
Contact:

Re: How to disable child test cases?

Post by nmathew » Thu Feb 26, 2015 3:43 pm

That worked. Thank you Markus!!