Reporting from API

Class library usage, coding and language questions.
i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Reporting from API

Post by i.vasilyev » Sat Apr 29, 2017 1:43 pm

Hello everyone.
I have a problem with setupping Test Report.

Environment:
C#
mstest
using Microsoft.VisualStudio.TestTools.UnitTesting

I'm doing following:

Code: Select all

[TestMethod]
        public void CodedUITestMethod1()
        {
            TestReport.Setup(ReportLevel.Debug, "report.rxlog", true);
            TestReport.BeginTestSuite("Testsuite");
            TestReport.BeginTestCase("Testcase");
            TestReport.BeginTestModule("Testmodule");

            Report.Info("Something to log");
            
            var calc = new Calculations();
            calc.ClickOk();
            TestReport.EndTestModule();
            TestReport.EndTestCase();
            TestReport.SaveReport();
        }
Ok button is not present on Calculations window, so test is failed with an error "No element found for path"
But my report.rxlog shows test as passed. What i'm doing wrong? Is it possible to configure it correctly?

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

Re: Reporting from API

Post by odklizec » Tue May 02, 2017 7:14 am

Hi,

Use Report.Failure (instead of Report.Info), which should set the test to failed state.
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

i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Re: Reporting from API

Post by i.vasilyev » Tue May 02, 2017 9:30 am

odklizec wrote:Use Report.Failure (instead of Report.Info), which should set the test to failed state.
Hello. I know that. But what about info mesages? And what about ElementNotFoundException?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Reporting from API

Post by Support Team » Wed May 03, 2017 1:46 pm

Hello i.vasilyev,

Thank you for posting this question in the forums!

I think what you are missing is "Report.End()" statement that should be run as the last line of code unless you need to submit some report totals to an API or something similar that happens after a test run.

Please make sure you have all the following lines in your solution

Code: Select all

TestReport.Setup(ReportLevel.Info, "MyAmazinglyAwesomeTestReport_%S_%M%D%Y_%T.rxlog", true);
TestReport.BeginTestSuite("TestSuiteName");
TestReport.BeginTestCase("TestCaseName");
TestReport.BeginTestModule("TestModuleNAme");
Report.Failure("Failure Reason");
TestReport.EndTestModule();
TestReport.EndTestCase();
TestReport.SaveReport();
Report.End();
Please note that because of test setups and teardowns these lines to not appear together like this in my solution. It is broken up into several sections. I even have try/catch blocks that look for exceptions, and then update the error reason. For error handling you might want to set up two variables. One is a bool called "testIsFailed", and the other is a string called "testFailureReason". This allows me to try/catch exceptions, and in my case I add a bunch of information on the failure to the report in a section that does not appear if the test is passed.

I can send you an example in NUnit if you like. NUnit is not that different than CodedUI. Please contact [email protected] if you would like this example.

I hope this information is helpful to you!

Sincerely,

-- M. Kendall McIntosh
Automation Support Engineer

i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Re: Reporting from API

Post by i.vasilyev » Sat May 06, 2017 4:55 pm

Hello. I've used you solution, but a have a problem with Duration value in report header. It shows 0ms always. By BeginTestCase time is correct. How can I fix this problem?
The same problem for Total errors. There are 1 failed test in reposrt, but Total errors = 0 in header
Support Team wrote:Hello i.vasilyev,

Thank you for posting this question in the forums!

I think what you are missing is "Report.End()" statement that should be run as the last line of code unless you need to submit some report totals to an API or something similar that happens after a test run.

Please make sure you have all the following lines in your solution

Code: Select all

TestReport.Setup(ReportLevel.Info, "MyAmazinglyAwesomeTestReport_%S_%M%D%Y_%T.rxlog", true);
TestReport.BeginTestSuite("TestSuiteName");
TestReport.BeginTestCase("TestCaseName");
TestReport.BeginTestModule("TestModuleNAme");
Report.Failure("Failure Reason");
TestReport.EndTestModule();
TestReport.EndTestCase();
TestReport.SaveReport();
Report.End();
Please note that because of test setups and teardowns these lines to not appear together like this in my solution. It is broken up into several sections. I even have try/catch blocks that look for exceptions, and then update the error reason. For error handling you might want to set up two variables. One is a bool called "testIsFailed", and the other is a string called "testFailureReason". This allows me to try/catch exceptions, and in my case I add a bunch of information on the failure to the report in a section that does not appear if the test is passed.

I can send you an example in NUnit if you like. NUnit is not that different than CodedUI. Please contact [email protected] if you would like this example.

I hope this information is helpful to you!

Sincerely,

-- M. Kendall McIntosh
Automation Support Engineer

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Reporting from API

Post by Support Team » Mon May 08, 2017 9:20 pm

Hello i.vasilyev,

I will look into this issue, and get back to you. I want to attempt to reproduce this on my side.

I did want to say that these two are different:

Report.Failure(string)

Report.Error(string)

So can you please attempt to use "Report.Error(string)" in your solution to see the error count increase.

Please standby. I will research this topic, attempt to reproduce, and get back to you. Thank you for your patience.

Please feel free to open a ticket for this issue at [email protected] (USA) or [email protected] (world wide) if you like. I will handle the ticket.

Sincerely,

-- M. Kendall McIntosh
Automation Support Engineer