New Report - how to code it?

Class library usage, coding and language questions.
User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

New Report - how to code it?

Post by artur_gadomski » Fri Mar 18, 2011 9: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
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: New Report - how to code it?

Post by sdaly » Fri Mar 18, 2011 11:00 am

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
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: New Report - how to code it?

Post by artur_gadomski » Fri Mar 18, 2011 1: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
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: New Report - how to code it?

Post by Support Team » Fri Mar 18, 2011 7: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
.
Image