Get Test Case Description

Class library usage, coding and language questions.
Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Get Test Case Description

Post by Vaughan.Douglas » Tue Jun 21, 2016 3:51 pm

Where is the text contained in the Ranorex UI "description" filed located and is it accessible through the API?

I've searched and found a solution that involved using the deprecated TestCase class, but I can't seem to find a suitable alternative.

Likewise I'd like to get the testcase execution duration value, but I haven't started the hunt for that one yet.
Doug Vaughan

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Get Test Case Description

Post by Vaughan.Douglas » Tue Jun 21, 2016 5:48 pm

I think I found what I needed in the TestCaseActivity class. I'm not sure this is the best approach, so if anyone has other suggestions, please let me know.

Code: Select all

            
ActivityStack.Instance.VisitAll(Function(a)
     Dim myTestCase As TestCaseActivity = TryCast(a, TestCaseActivity)
     If (myTestCase IsNot Nothing) Then
         MsgBox(myTestCase.TestCaseName)
         MsgBox(myTestCase.DetailMessage)
         MsgBox(myTestCase.TotalDuration)
     End If
     Return True
End Function)
Doug Vaughan

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

Re: Get Test Case Description

Post by odklizec » Wed Jun 22, 2016 8:20 am

Hi,

The 'obsolete' code you found does exactly what you want. You just have to adapt it for Ranorex 6.0. Luckily, the fix is pretty easy. Just replace TestCase with TestCaseNode and you are done ;)

Code: Select all

var tcDescription = TestCaseNode.Current as TestCaseNode;
Report.Info(tcDescription.Comment.ToString());
In case you want also module description, use this code:

Code: Select all

var modDescription = TestModuleLeaf.Current as TestModuleLeaf;
Report.Info(modDescription.Comment.ToString());
As for TC duration, check this post:
http://www.ranorex.com/forum/duration-o ... tml#p15772
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

Vaughan.Douglas
Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Get Test Case Description

Post by Vaughan.Douglas » Tue Jul 12, 2016 4:51 pm

The reporting requirements ask for results based at the testcase/iteration level. On one hand this is great because it significantly reduces the number of DB calls needed, but I don't have any context to put around a failure as I believe that is only available at the module level. Oh well. :D

I have found that getting the elapsed time is very straight forward:

Code: Select all

myTestCase.ElapsedTime.TimeSpan.TotalSeconds
As always, thanks for the insight.
Doug Vaughan