How to Get Time Duration of all completed test cases with code

Class library usage, coding and language questions.
sheafox
Posts: 33
Joined: Mon Jul 09, 2018 3:54 am

How to Get Time Duration of all completed test cases with code

Post by sheafox » Thu Oct 07, 2021 3:55 pm

I am trying to write to code to get the time duration of all completed tests cases in the final teardown routine of the test suite. Is this possible and if so how do I do it? I am using C# as my language.

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

Re: How to Get Time Duration of all completed test cases with code

Post by odklizec » Fri Oct 08, 2021 7:18 am

Hi,

This piece of code should help:

Code: Select all

using Ranorex.Core.Reporting;
var tm = TestReport.CurrentTestSuiteActivity;
var testDurarion = tm.TotalDuration.ToString();
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

sheafox
Posts: 33
Joined: Mon Jul 09, 2018 3:54 am

Re: How to Get Time Duration of all completed test cases with code

Post by sheafox » Fri Oct 08, 2021 2:04 pm

Thanks for the response. I am trying to get the test duration of each individual test case at the very end of of the test run. For example I want the test case 1 duration, test case 2 duration, and etc. Is this possible?

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

Re: How to Get Time Duration of all completed test cases with code

Post by odklizec » Fri Oct 08, 2021 2:12 pm

Hi,

I believe that you should use CurrentTestContainerActivity instead of CurrentTestSuiteActivity.
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

sheafox
Posts: 33
Joined: Mon Jul 09, 2018 3:54 am

Re: How to Get Time Duration of all completed test cases with code

Post by sheafox » Fri Oct 08, 2021 2:36 pm

Thanks. So I would have to run this code after each test case?