Get number of passed/failed test cases

Ranorex Spy, Recorder, and Studio.
gridle
Posts: 6
Joined: Mon Mar 10, 2014 5:13 pm

Get number of passed/failed test cases

Post by gridle » Wed Oct 10, 2018 8:53 am

Hi,

i know discussions of similar questions were here before but solutions of it didn't help me.
So i need to get number of passed and failed tests cases.
I created code module and put it in TearDown module.
Code:
var testSuite = Ranorex.Core.Reporting.TestReport.CurrentTestSuiteActivity;

var status = testSuite.Status;

var totalBlocked = testSuite.TotalBlockedTestCaseCount;
var totalFailed = testSuite.TotalFailedTestCaseCount;
var totalPassed = testSuite.testSuite.TotalSuccessTestCaseCount;
            
var total = totalPassed + totalFailed + totalBlocked;
var data = String.Format("Total:{0}{1}Passed:{2}{3}Failed:{4}", total, Environment.NewLine, totalPassed, Environment.NewLine, totalFailed);

Report.Log(ReportLevel.Info, data);
Status (testSuite.Status) is correct.
But numbers (totalBlocked/Failed/Passed) are returned as 0 only.

So is there are any way to get correct numbers?
Thanks!

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

Re: Get number of passed/failed test cases

Post by odklizec » Wed Oct 10, 2018 9:28 am

Hi,

I'm not sure if it's doable like this from the test suite's teardown section? But I'm sure it will work if you move this code to program.cs, just before 'return' line. Hope this helps?
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

gridle
Posts: 6
Joined: Mon Mar 10, 2014 5:13 pm

Re: Get number of passed/failed test cases

Post by gridle » Wed Oct 10, 2018 12:41 pm

odklizec wrote:
Wed Oct 10, 2018 9:28 am
But I'm sure it will work if you move this code to program.cs, just before 'return' line. Hope this helps?
Oh, thanks a lot! It works!