Hi,
displaying the starting time (timestamp) of a test case instead of the duration could be realized with the help of the ActivityStack. The ActivityStack provides information about test steps for the report allowing to add custom information ("CustomProperties"). Ranorex will add this information to the report data file, it will not be visible by default but it can be displayed with a simple modification in the transformation file (xslt).
First step - get starting time of Test Suite:
Note: Edited on 2015-08-27; Works for Ranorex Version >= 5.3:
// Get Starting Time
System.DateTime timestamp = Ranorex.Core.Reporting.ActivityStack.Current.BeginTime;
Now, run through all test cases in ActivityStack, calculate the starting time of each test case and add it as a the custom field:
// Iterate through all test cases, calculate starting time and add a custom field
Ranorex.Core.Reporting.ActivityStack.Instance.VisitAll(a =>
{
if(a.GetType().Name=="TestCaseActivity")
{
System.DateTime startTime = System.DateTime.Now - (a as Activity).ElapsedTime;
Report.Info (string.Format ("Started: {0:H:mm:ss}",startTime ));
(a as Activity).CustomProperties.Add("CustomFieldStartingTime", string.Format ("Started: {0:H:mm:ss}",startTime ));
}
return true;
});
Note: (Added on May 9,2014): If you additionally want to have the starting time next to each iteration of a loop, simply enhance the conditional statement and use the following one:
if (a.GetType().Name=="TestCaseActivity" || a.GetType().Name=="TestIterationActivity") ...
Important: Don't forget to update the ActivityStack:
Ranorex.Core.Reporting.ActivityStack.Update();
A final modification needs to be done in the transformation file (xslt):
Line 335: simply replace:
<span class="duration"><xsl:value-of select="./@duration"/></span>
with
<span class="duration"><xsl:value-of select=".//@CustomFieldStartingTime"/></span>
Updated 2014/05/05: closing span-tag has been added in the second line (Roland E)
Note (Added May 9, 2014): To additionally print out the starting time for every iteration in a loop please got to line 392 (in XSL-file)
<xsl:value-of select="./@duration"/>
and use
<xsl:value-of select=".//@CustomFieldStartingTime"/>
instead.
**********************************
Summary:
1.) Download the code module
AddStartTimeToReport.cs
2.) Add the code module "AddStartTimeToReport" to your test suite and place it in the "global" Teardown container
ActivityStack-TestSuite.gif
3.) Activate custom reporting in your Ranorex Solution. More details on custom reporting can be found here:
http://www.ranorex.com/support/user-gui ... html#c4898
4.) Download the zip archive, extract the sample xsl-file to your custom report folder (and overwrite the existing one):
RanorexReport5.zip
Your report should look like this now:
ActivityStack-Report.gif
Please let us know in case there are any additional questions!
With kind regards
Ranorex Team
Roland (E)