Enable String Parameters in Report.Debug/Info/Etc.

Class library usage, coding and language questions.
Frederiksen78
Posts: 3
Joined: Mon Feb 04, 2013 3:49 pm

Enable String Parameters in Report.Debug/Info/Etc.

Post by Frederiksen78 » Mon Feb 04, 2013 4:06 pm

I'm not sure if this is the right forum to post general requests or comments, but feel free to move it to an appropriate forum if it isn't. Thanks.

Quite often when writing to the Ranorex Report, I want to include some additional information. For instance which window was detected, which button was pressed or what the contents of a text box was. Whenever I want to write this to the report, I have to use a string.Format inside. It's not a big problem, but it would be really helpful if the Report.Debug/Info/others would automatically accept string parameters in the same way as the Console.WriteLine does by default.

So, instead of writing:

Code: Select all

Report.Debug(string.Format("Available Memory is '{0}'MB", repo.TextField.Text));
I would write:

Code: Select all

Report.Debug("Available Memory is '{0}'MB", repo.TextField.Text);
It's not much time saved in just one instance, but it helps when writing a lot of text to the report over the course of many thousand lines of test automation code.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Enable String Parameters in Report.Debug/Info/Etc.

Post by krstcs » Mon Feb 04, 2013 8:47 pm

You could create a custom code module with extension methods for each of the Report methods you need to be able to format.

Code: Select all

public static class ReportExtensions {
  public static void Info(this Report rpt, string Message, params string[] FormatParameters) {
    rpt.Info(string.Format(Message, FormatParameters));
  }
}
and then use it...

Code: Select all

...
Report.Info("Test Message with Params({0}, {1})", "test param 1", "test param 2");
...
and so on...

It would be handy if Ranorex already did this, but if the extensions work for you, you could further customize as needed.
Shortcuts usually aren't...

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

Re: Enable String Parameters in Report.Debug/Info/Etc.

Post by Support Team » Tue Feb 05, 2013 2:52 pm

Hello,

Currently, we don't support parameters in strings.
I will forward this feature request to our developers.

Regards,
Markus (T)
.
Image

Frederiksen78
Posts: 3
Joined: Mon Feb 04, 2013 3:49 pm

Re: Enable String Parameters in Report.Debug/Info/Etc.

Post by Frederiksen78 » Tue Feb 05, 2013 3:58 pm

Thank you, krstcs and Markus.