Page 1 of 1

How To get the test case status in a condition

Posted: Wed Jul 04, 2018 12:43 pm
by DavidH
Hi,

I'm trying to receive the test case status in the teardown.
testsuite.JPG
I'm using the following code:

Code: Select all

ITestContainer TestContainer = TestSuite.Current.CurrentTestContainer;
        	while(!TestContainer.IsTestCase){
        		TestContainer = TestContainer.ParentContainer;
        	}
        	Report.Log(ReportLevel.Info, TestContainer.Status.ToString());
This returns me the correct status for "normal" test cases, but if the testcase is inside a conditional smart folder it returns always the status "ignored". :?
How do I get the correct testcase status?

Re: How To get the test case status in a condition

Posted: Wed Jul 04, 2018 4:44 pm
by odklizec
Hi,

Try this code for test case or entire test suite status...

Code: Select all

var tcStatus = TestSuite.Current.GetTestContainer("tcName").Status; // get status of specified TC 
var tcStatus = Ranorex.Core.Reporting.ActivityStack.Current.Status; // returns test suite status

Re: How To get the test case status in a condition

Posted: Wed Aug 08, 2018 1:10 pm
by DavidH
odklizec wrote:
Wed Jul 04, 2018 4:44 pm
Hi,

Try this code for test case or entire test suite status...

Code: Select all

var tcStatus = TestSuite.Current.GetTestContainer("tcName").Status; // get status of specified TC 
var tcStatus = Ranorex.Core.Reporting.ActivityStack.Current.Status; // returns test suite status
Unfortunatly this isn't working for my version of Ranorex.

Code: Select all

ITestContainer TestContainer = TestSuite.Current.CurrentTestContainer;
        	while(!TestContainer.IsTestCase){
        		TestContainer = TestContainer.ParentContainer;
        	}
        	Report.Log(ReportLevel.Info, TestSuite.Current.GetTestContainer( TestContainer.Name).Status.ToString())
        	Report.Log(ReportLevel.Info, TestSuite.Current.GetTestContainer("TestCase2").Status.ToString());
        	
Both report records returned me the status "ignored".
I've tested this in the latest version of Ranorex, and there the issue isn't occuring. Unfortunatly the client isn't able to upgrade for now.