How to set ReportSettings.ReportEnabled

Ask general questions here.
gri
Posts: 5
Joined: Wed Oct 26, 2022 6:43 am

How to set ReportSettings.ReportEnabled

Post by gri » Wed Nov 30, 2022 2:21 pm

Hi

In ranorex studio I create a new project, add an usercodemodule with a single line of code.

Code: Select all

WinForms.MessageBox.Show(TestSuite.Current.ReportSettings.ReportEnabled.ToString());
This shows true/ false dependig of the checkbox state in Testsuite>>Properties>>Report>>Enable report. Thats OK

So I enabled the checkbox and tried to disable the report creation at runtime with this:

Code: Select all

TestSuite.Current.ReportSettings.ReportEnabled = false;
But the report is always created. I tried this at additional "places" like in setup/ teardown but cant disable the report creation.

So the question is: gets the property ReportSettings.ReportEnabled internal ignored or how to use this?
What I want to archieve is to disable report creation at runtime,


version is 10.2.2
regards,
Maik

IvanF
Posts: 151
Joined: Thu Aug 11, 2022 8:55 pm

Re: How to set ReportSettings.ReportEnabled

Post by IvanF » Wed Nov 30, 2022 2:57 pm

Hi,

Looks like one of the "setup" methods should be responsible for the enable/disable action, you can try either

Ranorex.Core.Reporting.TestReport.Setup(ReportLevel.None, null, false);

or

Ranorex.Report.Setup(ReportLevel.None, null, false);

Let me know if neither works.

gri
Posts: 5
Joined: Wed Oct 26, 2022 6:43 am

Re: How to set ReportSettings.ReportEnabled

Post by gri » Wed Nov 30, 2022 3:47 pm

Because ReportLevel.None is obsolete I tried following:

Code: Select all

	Report.MinimumReportLevel = ReportLevel.Failure; // raise to 120 
	Ranorex.Core.Reporting.TestReport.Setup(Report.MinimumReportLevel  ,null,false);
	Ranorex.Report.Setup(Report.MinimumReportLevel,null,false);
Without sucess....report is still generated.

IvanF
Posts: 151
Joined: Thu Aug 11, 2022 8:55 pm

Re: How to set ReportSettings.ReportEnabled

Post by IvanF » Wed Nov 30, 2022 8:39 pm

I see, maybe one of these methods could work instead:

https://www.ranorex.com/Documentation/R ... rt_End.htm (if used upfront instead of near teardown)

https://www.ranorex.com/Documentation/R ... _Clear.htm

https://www.ranorex.com/Documentation/R ... Report.htm (setting this to false, if possible)

gri
Posts: 5
Joined: Wed Oct 26, 2022 6:43 am

Re: How to set ReportSettings.ReportEnabled

Post by gri » Thu Dec 01, 2022 11:51 am

Hi,

I played around with the suggested methods. But did not get the expected result.
Report is always generated.

Only thing that worked for me and prevent the report processing is an brutal way with an compiler warning because of obsolete in future.
But is still working yet.

Code: Select all

Ranorex.Core.Reporting.TestReport.ReportFilename=null;
Not smart but works.

IvanF
Posts: 151
Joined: Thu Aug 11, 2022 8:55 pm

Re: How to set ReportSettings.ReportEnabled

Post by IvanF » Thu Dec 01, 2022 2:07 pm

I see, thanks for sharing the workaround, I'll keep an eye out for any API doc updates regarding reports in the future.