Coding with the reporting API

Class library usage, coding and language questions.
boby
Posts: 9
Joined: Fri Apr 11, 2014 9:35 am

Coding with the reporting API

Post by boby » Thu May 22, 2014 7:43 am

Hi,

is there any tutorial on how to use the reporting API (without using the Ranorex Studio, e.g. with VS)?

I have searched quite a lot of this forum as well as the user guide, but could not figure out how to achieve it step by step.

I have the following code, for example:

Code: Select all

       [ClassInitialize]
       public static void StartReporting(TestContext context)
        {
            TestReport.Setup(ReportLevel.Debug, @"C:\temp\report.html", true);
            TestReport.EnableTracingScreenshots = true;
            Ranorex.Validate.EnableReport = true;
            TestReport.ReportWriteInterval = 0;
        }

        [TestMethod]
        public void ReportingTest1()
        {
            Assert.IsFalse(false);
        }

        [TestMethod]
        public void ReportingTest2()
        {
            Assert.IsFalse(true);
            Assert.IsTrue(true);
         }

        [TestCleanup]
        public void TestCleanUp()
        {
            TestReport.EndTestCase();
            TestReport.SaveReport();
        } 
What I would like to have in the report are, at least: Name of the test case (test method in this case), test result(pass/fail), etc.

The report generated has no such information and it's empty. What's wrong with my coding?

Great thanks in advance!

Kind regards,
boby

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Coding with the reporting API

Post by Support Team » Fri May 23, 2014 2:44 pm

Hello boby,

Unfortunately we currently do not have a tutorial on how to use the reporting API. Please check out following blog post which covers your requests:

http://www.ranorex.com/forum/ranorex-re ... t3022.html

Regards,
Robert
.
Image

boby
Posts: 9
Joined: Fri Apr 11, 2014 9:35 am

Re: Coding with the reporting API

Post by boby » Mon May 26, 2014 9:53 am

Hi Robert,

thanks for your reply!

Yes, i did have read the post and it shows the basic routine how to get a report with VS.

But I have not found the guide how to log only the Test Method and the result of the execution into the report. This is in fact what i really want.

Thanks!

Kind regards,
Boby

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Coding with the reporting API

Post by Support Team » Tue May 27, 2014 3:00 pm

Hi boby,

The problem is that you need to tell the Ranorex Report that something happened otherwise it won’t be displayed. E.g.,
[TestMethod]
        public void MyCodedUIMethod()
        {
            Report.Info("MyMessage");
            Validate.IsFalse(true);
            
        }
Results in:
UnitTest_report.png
UnitTest_report.png (16.42 KiB) Viewed 1120 times
Please let me know if you need any further guidance.

Regards,
Robert
.
Image

boby
Posts: 9
Joined: Fri Apr 11, 2014 9:35 am

Re: Coding with the reporting API

Post by boby » Wed May 28, 2014 8:46 am

Hi Robert,

thank you again for your answer!

I see what you mean. The problem for our case is that we have thousand testcases, and if we have to add message for each testcase it would be quite time consuming. What I would like to have is that whether is there a way that Ranorex report could log each testcase with its execution result and show a screenshot if any error occurs.

Kind regards,
Boby

User avatar
Support Team
Site Admin
Site Admin
Posts: 11710
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Coding with the reporting API

Post by Support Team » Fri May 30, 2014 12:33 pm

Hello Boby,

I’m afraid that there is no out-of-the-box solution for your requirements. You will have to implement the necessary steps on your own.

Thank you for your understanding.

Regards,
Robert
.
Image