Page 1 of 1

Get number of passed/failed test cases

Posted: Wed Oct 10, 2018 8:53 am
by gridle
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!

Re: Get number of passed/failed test cases

Posted: Wed Oct 10, 2018 9:28 am
by odklizec
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?

Re: Get number of passed/failed test cases

Posted: Wed Oct 10, 2018 12:41 pm
by gridle
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!