How do i capture module results in variable at runtime

Experiences, small talk, and other automation gossip.
bhavna.nawani
Posts: 5
Joined: Fri Apr 19, 2019 8:45 am

How do i capture module results in variable at runtime

Post by bhavna.nawani » Wed Apr 24, 2019 12:54 pm

Hi,

I am new to Ranorex, My project have 1 requirement to create summary report for multiple test execution runs.

The best way to achieve this is by storing test suit results in database (Oracle for e.g.)

However I am unable to figure out on how to capture below basic test results at runtime?
Test Case Name
Module Name
Execution Time stamp
Execution Result

If I am able to capture these values at runtime and store it in a variable then i can pass them to database for storing.

Appreciate quick response as i am currently stuck with this :(

Thanks
Bhavna

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: How do i capture module results in variable at runtime

Post by Vega » Fri Apr 26, 2019 5:56 am

I believe the TestReport class should be able to give you everything you need:
https://www.ranorex.com/Documentation/R ... Report.htm

Example:

Code: Select all

Report.Info("Test case: " + TestSuite.Current.CurrentTestContainer.Name);
Report.Info("Test module: " + TestReport.CurrentTestModuleActivity.TestModuleName);
Report.Info("Result: " + TestReport.CurrentTestModuleActivity.Status.ToString());
Report.Info("Elapsed Time: " + TestReport.CurrentTestModuleActivity.ElapsedTime.ToString());
output:

Code: Select all

Test case: Test_Case_example123 
Test module: Recording1  
Result: Success  
Elapsed time: 143ms  
There are some helpful threads here:
get-name-of-test-module-within-code-t2177.html
where-to-get-the-elapsed-time-for-entre ... 12651.html

hope this helps

bhavna.nawani
Posts: 5
Joined: Fri Apr 19, 2019 8:45 am

Re: How do i capture module results in variable at runtime

Post by bhavna.nawani » Fri Apr 26, 2019 1:18 pm

Thank You Vega,

However i have a specific requirement: Refer to attached test suite heirarchy

I need to store test results in variable:
TestCase Name
Test Execution DateTime
Total Elapsed Time for execution
Test Case result
If Failed, then show failed Module Name and error details.

Please let me know how I can capture that and also where should i place my code so that it runs every time even if the Module is failed.

Thanks
Bhavna
You do not have the required permissions to view the files attached to this post.

Vega
Posts: 222
Joined: Tue Jan 17, 2023 7:50 pm

Re: How do i capture module results in variable at runtime

Post by Vega » Tue Apr 30, 2019 4:20 am

Well if you want your code to execute no matter what, then you would place it in a teardown region for the test case. This way even if the test case passes or fails, your code will always be executed.

Hope this helps

kennethburson
Posts: 1
Joined: Thu Mar 25, 2021 10:33 am

Re: How do i capture module results in variable at runtime

Post by kennethburson » Thu Mar 25, 2021 10:48 am

I am new to Ranorex, My project have 1 requirement to create summary to write my essay report for multiple test execution runs. However I am unable to figure out on how to capture below basic test results at runtime?
The most useful link on storing hierarchical data in a relational database: https://www.codeproject.com/Articles/27 ... ierarchies