Page 1 of 1

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

Posted: Mon Feb 04, 2013 4:06 pm
by Frederiksen78
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.

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

Posted: Mon Feb 04, 2013 8:47 pm
by krstcs
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.

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

Posted: Tue Feb 05, 2013 2:52 pm
by Support Team
Hello,

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

Regards,
Markus (T)

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

Posted: Tue Feb 05, 2013 3:58 pm
by Frederiksen78
Thank you, krstcs and Markus.