private static IEnumerable <testsuiteProperty> ConvertTestsuiteProperties(ActionIterationReport actionIterationReport) { List <testsuiteProperty> list = new List <testsuiteProperty>(); // action iteration index list.Add(new testsuiteProperty(Properties.Resources.PropName_ActionIterationIndex, actionIterationReport.Index.ToString())); // iteration input/output parameters foreach (ParameterType pt in actionIterationReport.InputParameters) { list.Add(new testsuiteProperty(Properties.Resources.PropName_Prefix_ActionIterationInputParam + pt.NameAndType, pt.value)); } foreach (ParameterType pt in actionIterationReport.OutputParameters) { list.Add(new testsuiteProperty(Properties.Resources.PropName_Prefix_ActionIterationOutputParam + pt.NameAndType, pt.value)); } // owner - action ActionReport actionReport = actionIterationReport.OwnerAction; if (actionReport != null) { // action name list.Add(new testsuiteProperty(Properties.Resources.PropName_Action, actionReport.Name)); // action properties list.AddRange(ConvertTestsuiteProperties(actionReport)); } return(list); }
private static testsuiteTestcase[] ConvertTestcases(ActionIterationReport actionIterationReport, out int count, out int numOfFailures) { count = 0; numOfFailures = 0; List <testsuiteTestcase> list = new List <testsuiteTestcase>(); EnumerableReportNodes <StepReport> steps = new EnumerableReportNodes <StepReport>(actionIterationReport.AllStepsEnumerator); foreach (StepReport step in steps) { testsuiteTestcase tc = ConvertTestcase(step, count); if (tc == null) { continue; } list.Add(tc); if (step.Status == ReportStatus.Failed) { numOfFailures++; } count++; } return(list.ToArray()); }
/// <summary> /// Converts the specified <see cref="ActionIterationReport"/> to the corresponding JUnit <see cref="testsuitesTestsuite"/>. /// </summary> /// <param name="actionIterationReport">The <see cref="ActionIterationReport"/> instance contains the data of an action iteration.</param> /// <param name="index">The index, starts from 0, to identify the order of the testsuites.</param> /// <returns>The converted JUnit <see cref="testsuitesTestsuite"/> instance.</returns> private testsuitesTestsuite ConvertTestsuite(ActionIterationReport actionIterationReport, int index) { // get owner action and iteration data string actionName = string.Empty; int iterationIndex = 0; if (actionIterationReport.OwnerAction != null) { actionName = actionIterationReport.OwnerAction.Name; // owner iteration if (actionIterationReport.OwnerAction.OwnerIteration != null) { iterationIndex = actionIterationReport.OwnerAction.OwnerIteration.Index; } } // a GUI test action iteration is converted to a JUnit testsuite testsuitesTestsuite ts = new testsuitesTestsuite(); ts.id = index; // Starts at '0' for the first testsuite and is incremented by 1 for each following testsuite ts.package = Input.TestAndReportName; // Derived from testsuite/@name in the non-aggregated documents // sample: GUI-00012: Iteration 1 / Action 3 / Action Iteration 2 ts.name = string.Format("GUI-{0,5:00000}: {1} {2} / {3} / {4} {5}", index + 1, Properties.Resources.PropName_Iteration, iterationIndex, actionName, Properties.Resources.PropName_ActionIteration, actionIterationReport.Index); // other JUnit required fields ts.timestamp = actionIterationReport.StartTime; ts.hostname = Input.HostName; if (string.IsNullOrWhiteSpace(ts.hostname)) { ts.hostname = "localhost"; } ts.time = actionIterationReport.DurationSeconds; // properties List <testsuiteProperty> properties = new List <testsuiteProperty>(ConvertTestsuiteCommonProperties(actionIterationReport)); properties.AddRange(ConvertTestsuiteProperties(actionIterationReport)); ts.properties = properties.ToArray(); // JUnit testcases int testcaseCount = 0; int failureCount = 0; ts.testcase = ConvertTestcases(actionIterationReport, out testcaseCount, out failureCount); ts.tests = testcaseCount; ts.failures = failureCount; return(ts); }