How To get the test case status in a condition

Best practices, code snippets for common functionality, examples, and guidelines.
DavidH
Posts: 5
Joined: Mon Jan 22, 2018 2:49 pm

How To get the test case status in a condition

Post by DavidH » Wed Jul 04, 2018 12:43 pm

Hi,

I'm trying to receive the test case status in the teardown.
testsuite.JPG
testsuite.JPG (26.16 KiB) Viewed 276 times
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?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

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

Post by odklizec » 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
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

DavidH
Posts: 5
Joined: Mon Jan 22, 2018 2:49 pm

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

Post by DavidH » Wed Aug 08, 2018 1:10 pm

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.