Page 1 of 1
New Report - how to code it?
Posted: Fri Mar 18, 2011 9:30 am
by artur_gadomski
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.
Re: New Report - how to code it?
Posted: Fri Mar 18, 2011 11:00 am
by sdaly
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();
Re: New Report - how to code it?
Posted: Fri Mar 18, 2011 1:28 pm
by artur_gadomski
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.
Re: New Report - how to code it?
Posted: Fri Mar 18, 2011 7:46 pm
by Support Team
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
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