Sending an email of Test Results

Ask general questions here.
User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Sending an email of Test Results

Post by Support Team » Tue Nov 06, 2012 5:51 pm

Hi,

That's often the case ;).
You could copy the following files to the machine where you want to open the report files and where Ranorex is not installed: Ranorex.Controls.dll, Ranorex.Core.dll and the Ranorex.ReportViewer.exe.
You can now open the report with the ReportViewer, just double click on the exe and select your report file.

Regards,
Markus

jchou
Posts: 26
Joined: Tue Apr 24, 2012 11:19 pm

Re: Sending an email of Test Results

Post by jchou » Wed Nov 07, 2012 1:18 am

I've got the answers of my question (from Roland of Rx). Thanks.

jchou
Posts: 26
Joined: Tue Apr 24, 2012 11:19 pm

Re: Sending an email of Test Results

Post by jchou » Wed Nov 07, 2012 1:26 am

Thought it might be helpful to some people who don't know yet, I post Roland's answer here:

in general a Ranorex Report is an XML-based file. Next to this xml-file, a stylesheet (*.xsl) is needed for displaying and, in some situations, also a Ranorex Logo and Screenshots are needed if they are referenced. So once you copy all necessary files to a machine, where Ranorex is not installed, you can open the report nevertheless. There are two ways:

1.)
As Tobias pointed out, the extension has to be changed from rxlog to xml and it can be opened in IE (or other Browsers or XML-Viewers). Take Care: Since there is JavaScript code in Background, the Browser might suppress parts of the Report. In IE, a small bar comes up at the bottom of the report asking you if you would like to allow JavaScript/ActiveX functionality. Once you confirm that, everything should be displayed as usual.



2.)
You can also use the Ranorex Report Viewer on machines without having a valid Ranorex License (or having Ranorex installed). Therefore be sure that the following files are copied to the new machine:
Ranorex.Controls.dll
Ranorex.Core.dll
AND Ranorex.ReportViewer.exe
(All these files can be found in your Ranorex Installation Folder in the BIN-Subdirectory)

Once you double-click the ReportViewer you will be asked to specify a Rxlog (or rxzlog)-File. Here we go!

If you’re working with the zipped-Version of Ranorex Reports (RXZLOG-files), you have to extract the archive first before continuing with the procedure described above. (JChou: Also, if you include one more Rx lib, "Ranorex.libs.dll", also available in Ranorex' bin (C:/program files (x86)/Ranorex3.3/bin), then you can open either the regular reports (.rxlog) and the compressed ones (.rxzlog) through the Rx report viewer.)

jchou
Posts: 26
Joined: Tue Apr 24, 2012 11:19 pm

Re: Sending an email of Test Results

Post by jchou » Wed Nov 07, 2012 4:14 am

Hi Marcus,

In your sample code, SendReportAndStatus, in End() of MailLogger.cs, there is a piece of code packing alternative html plain view into the mail:

// add html email part
AlternateView htmlPlainView = AlternateView.CreateAlternateViewFromString(
htmlText, null, MediaTypeNames.Text.Html);
foreach (LinkedResource res in linkedResources)
htmlPlainView.LinkedResources.Add(res);
mail.AlternateViews.Add(htmlPlainView);

Does that mean I can open a plain HTML view of the report if I want to? If so, how do I do that?

Thank.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Sending an email of Test Results

Post by Support Team » Thu Nov 08, 2012 5:02 pm

Hello,

The following lines of code
// add html email part
AlternateView htmlPlainView = AlternateView.CreateAlternateViewFromString(
htmlText, null, MediaTypeNames.Text.Html);
foreach (LinkedResource res in linkedResources)
	htmlPlainView.LinkedResources.Add(res);
mail.AlternateViews.Add(htmlPlainView);
do not provide a HTML view of your report that is attached to the email. This alternative view is used for e-mail clients which uses HTML as format to display messages instead of plain text. If you want to open the report with Internet Explorer you could rename the extension of your rxlog-file to xml.

Regards,
Markus (T)

jchou
Posts: 26
Joined: Tue Apr 24, 2012 11:19 pm

Re: Sending an email of Test Results

Post by jchou » Thu Nov 08, 2012 11:00 pm

I see. Thanks, Marcus.

jchou
Posts: 26
Joined: Tue Apr 24, 2012 11:19 pm

Re: Sending an email of Test Results

Post by jchou » Mon Nov 12, 2012 10:10 pm

Hi Markus (sorry, I'd been calling you "Marcus"),

I have one more question. When I was trying to log one line test result of each test case iteration in my email report (using Testcase.Current.Status.toString()), I ran into a problem that if one of the iterations failed, the rest iterations would all showed as "Failed", regardless if they were actually successful or failed. It looked like Testcase.Current.Status.toString() was not updated after once it's set to "Failed". For example, If there were three iterations, and only the second iteration failed, the logged test result would show both the second iteration and the third iteration as failed.
On the other hand, the test case iteration status in your sample report does not have such problem, and shows the correct status (see output sample below).
Therefore, my question is: instead of calling Testcase.Current.Status.toString(), how do I retrieve the test case iteration status as you did in your sample scripts (SendReportAndStatusPerMail.zip in this post)?

Thanks.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Sending an email of Test Results

Post by Support Team » Tue Nov 13, 2012 1:06 pm

Hi,

No problem ;).
If you want to log the status of the current test case iteration you have to do it in the teardown section of the test case, otherwise you won't get the current test case iteration status.

Regards,
Markus

jchou
Posts: 26
Joined: Tue Apr 24, 2012 11:19 pm

Re: Sending an email of Test Results

Post by jchou » Wed Nov 14, 2012 1:18 am

Hi Markus,

The code is already in the Teardown session. But TestCase.Current.Status seems not being updated as soon as one iteration fails, and stays as "Failed" through the rest of the iterations. As in your sample code, checkState() method is called in the email module in the teardown session. TestCase.Current.Status there would be "Failed" for the rest of the iterations if one iteration fails. On the other hand, in the email report generated by your SendReportAndStatusPerMail, the test case status for iteration showing in the following line was correct:
"2012/11/13 15:54:13.806 FAILURE Test Test Case 'TestCase' completed with status 'Failed'."

How could I create an email report with just one such line for each iteration? In other words, how could I retrieve the status in that line?

Thanks.

Joe

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Sending an email of Test Results

Post by Support Team » Wed Nov 14, 2012 3:12 pm

Hi,

May I ask you which Ranorex version you are using?
There was an issue with older Ranorex versions where the status wasn't updated.

Regards,
Markus

jchou
Posts: 26
Joined: Tue Apr 24, 2012 11:19 pm

Re: Sending an email of Test Results

Post by jchou » Fri Nov 16, 2012 9:28 pm

Hi Markus,

I am using Ranorex3.3.3.
How do I get the current report level to pass into logText method call? For example, instead of passing in report level Error:
LogText(ReportLevel.Error, ServerURL,TestCase.Current.Status.ToString(), ...);
Is there a way to pass in the current report level?
I am thinking to use report level to decide what status to be logged into email. Would that work?

Thanks.

Joe

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Sending an email of Test Results

Post by Support Team » Mon Nov 19, 2012 11:00 am

Hi Joe,

If I got you correctly this can be already done in the MailLogger, see the definition of the LogText method.
There is a if statement where you can define which log messages with which report level should be logged into the email (see ReportLevelMail property of the MailLogger class).
This method implements the method of the IReportLogger interface for Ranorex 3.X.The Report class calls this method for each attached IReportLogger instance when the Report.Log method is called.

What do you mean with the "current report level"?

Regards,
Markus

jchou
Posts: 26
Joined: Tue Apr 24, 2012 11:19 pm

Re: Sending an email of Test Results

Post by jchou » Mon Nov 19, 2012 7:57 pm

Hi Markus,

Thanks for you reply. "Current report level" I meant the report level of the current iteration of a test case (I need to repeat a test case for multiple app servers). The reason I asked for that is in your sample code (SendReportAndStatusPerMail), in the email report, the level of each iteration of my test case appears to be the same as the correct iteration status (level "SUCCESS" matches iteration "Succeed", and so does "FAILURE"). Therefore, I am thinking maybe I can use that level value to determine what iteration status to log. Would that work?

Thanks.

Joe

jchou
Posts: 26
Joined: Tue Apr 24, 2012 11:19 pm

Re: Sending an email of Test Results

Post by jchou » Mon Nov 19, 2012 8:10 pm

If using report level as indication of iteration status would be OK, then I am looking for what to use as the report level, the first parameter in LogText() method when I call it. Does ReportLevel have something I can use?
On the other hand, if this won't work, it would be OK too. Since I just heard today that in Ranorex 4.0 there will be a new value available for iteration status:
TestReport.CurrentIterationActivity.Status.ToString()

And that would solve my problem handily.

Thanks a lot, Markus.

Joe

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Sending an email of Test Results

Post by Support Team » Tue Nov 20, 2012 1:23 pm

Hi Joe,

I would just wait for version 4.0, in my opinion this would be the easiest solution if this is also okay for you?

Regards,
Markus