New Report - how to code it? : Automation API

New Report - how to code it?

Class library usage, coding and language questions.

New Report - how to code it?

Postby artur_gadomski » Fri Mar 18, 2011 10:30 am

Hi
I really like how the new report looks like, but since we're not using recordings and we co all out code in Visual Studio I was wondering if there is a way to achieve the same results with just coding.
User avatar
artur_gadomski
 
Posts: 125
Joined: Mon Jul 19, 2010 7:55 am
Location: Copenhagen, Denmark

Re: New Report - how to code it?

Postby sdaly » Fri Mar 18, 2011 12:00 pm

Try this...

Code: Select all
using Ranorex.Core.Reporting;

                //set up test report
                TestReport.Setup(ReportLevel.Info, "report.rxlog", true);
                TestReport.EnableTracingScreenshots = false;
                TestReport.ReportWriteInterval = 0;
                //show progress form
                Ranorex.Controls.ProgressForm.Show();

                //Shows Test Suite name and running test name in progress form
                using (new ActivityContext(new TestSuiteActivity("TestSuiteName", "", 0, null, "", "")))
                {
                    using (new ActivityContext(new TestCaseActivity("TestName", "", "", "", 0, 0, null, "", null)))
                    {
                    }
                }

               
                Report.Info("Hello");

                TestReport.SaveReport();
User avatar
sdaly
 
Posts: 213
Joined: Mon May 10, 2010 12:04 pm
Location: Dundee, Scotland

Re: New Report - how to code it?

Postby artur_gadomski » Fri Mar 18, 2011 2:28 pm

Thx. This took us half way and we were able to go to about 99% from there on our own. Final code is:

TestReport.Setup(ReportLevel.Debug, "report.rxlog", true);
TestReport.EnableTracingScreenshots = false;
TestReport.ReportWriteInterval = 0;
//show progress form
Ranorex.Controls.ProgressForm.Show();
using (new ActivityContext(new TestSuiteActivity("Test Suite Name", "", 0, null, "", "")))
{
    using (new ActivityContext(new TestCaseActivity("Test Case Name", "", "", "", 0, 0, null, "", null)))
    {
        using (new ActivityContext(new TestModuleActivity("Test Module Name", "", "", ModuleType.UserCode)))
        {             
            Report.Info("Message");
            Report.Failure("Message");
        }
        Report.Failure(""); // Causes test case to have failure status.
    }           
}
TestReport.SaveReport();


We still don't know how to make this fancy Circle with test status, or why we need secodn report failure/success in test case level, but what we have looks good enough for now.
User avatar
artur_gadomski
 
Posts: 125
Joined: Mon Jul 19, 2010 7:55 am
Location: Copenhagen, Denmark

Re: New Report - how to code it?

Postby Support Team » Fri Mar 18, 2011 8:46 pm

As you can see the new Reporting API is a bit ugly because it is only used by the Ranorex test suite code internally :?

But since a lot of people seem to be using it outside of the Ranorex Studio test suite, we will add a few overloads, utility methods, api doc and generally clean it up a little. There might also be a blog on how to use those fancy circles :D

These (non-breaking) changes will then probably make it into 3.0.1 and/or 3.0.2
Any suggestions are of course welcome.

@artur
You can set the current activity status by setting ActivityStack.Current.Status = ...
Then you dont need to do the rather weird Report.Failure() call.

Michael
Ranorex Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests

cron