Page 1 of 1

Code to execute at the start of every test case

Posted: Mon May 16, 2016 2:47 pm
by stapes
Is there a way I can make a bit of code that will be run at the start of every test case?

I am interested in seeing the Report Level & Error Behaviour of each Test Case.

i.e.

Code: Select all

var ts=TestSuite.Current;  
        	var tc1=(TestCase) TestCase.Current ;
        	Report .Info ("Report Level. Get Level:" + tc1.ReportLevel.ToString ());
            tc1.ReportLevel=Common.GlobalVariables.GlobalLevel; 
            Report .Info ("Set Report Level. Set Level:" + tc1.ReportLevel.ToString ());
            Report .Info ("Error Behavior. Get Error Behavior:" + tc1.ErrorBehavior.ToString ());

Re: Code to execute at the start of every test case

Posted: Mon May 16, 2016 3:22 pm
by krstcs
The only way to do it in Ranorex Studio would be to make a new UserCode module and then drop it into the SETUP section of each test case where you needed the info.

Re: Code to execute at the start of every test case

Posted: Mon May 16, 2016 4:44 pm
by stapes
I don't see that SETUP does anything but stick a label on your test report.
I already have this class at the start of every Test Case. I was just wondering if there was an override method I could use to do this.

Re: Code to execute at the start of every test case

Posted: Mon May 16, 2016 4:58 pm
by krstcs
No, there's no override method for the test cases. If you want to make a feature request, you can send it to [email protected].


The SETUP and TEARDOWN sections are run regardless of current test status (Success, Failed, etc.). They do label and segregate the test modules inside them so the test cases are a bit easier to read, but the real benefit of them is that they run no matter what the status is.

Re: Code to execute at the start of every test case

Posted: Mon May 16, 2016 5:07 pm
by stapes
Ah. That is helpful. Thanks.