private static testsuiteTestcase ConvertTestcase(CheckpointReport checkpointReport, int index) { if (checkpointReport == null || string.IsNullOrWhiteSpace(checkpointReport.CheckpointType)) { // not a checkpoint or checkpoint type is empty - ignore return(null); } // sample: Standard Checkpoint (DB Checkpoint) - "checkpoint 1" string checkpointDisplayName = checkpointReport.CheckpointType; if (!string.IsNullOrWhiteSpace(checkpointReport.CheckpointSubType)) { checkpointDisplayName += string.Format(" ({0})", checkpointReport.CheckpointSubType); } checkpointDisplayName += " - " + checkpointReport.Name; testsuiteTestcase tc = new testsuiteTestcase(); tc.name = string.Format("#{0,5:00000}: {1}", index + 1, checkpointDisplayName); tc.classname = checkpointReport.StepReport.TestObjectPath; tc.time = checkpointReport.StepReport.DurationSeconds; if (checkpointReport.Status == ReportStatus.Failed) { testsuiteTestcaseFailure failure = new testsuiteTestcaseFailure(); failure.message = checkpointReport.FailedDescription; failure.type = string.Empty; tc.Item = failure; } return(tc); }
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="StepReport"/> to the corresponding JUnit <see cref="testsuiteTestcase"/>. /// </summary> /// <param name="stepReport">The <see cref="StepReport"/> instance contains the data of a GUI test step.</param> /// <param name="index">The index, starts from 0, to identify the order of the testcases.</param> /// <returns>The converted JUnit <see cref="testsuiteTestcase"/> instance.</returns> public static testsuiteTestcase ConvertTestcase(StepReport stepReport, int index) { // the step might be a checkpoint CheckpointReport checkpointReport = CheckpointReport.FromStepReport(stepReport); if (checkpointReport != null) { return(ConvertTestcase(checkpointReport, index)); } // a step with smart identification? if (stepReport.SmartIdentification != null) { return(ConvertTestcaseWithSmartIdentificationInfo(stepReport, index)); } // a general step testsuiteTestcase tc = new testsuiteTestcase(); tc.name = string.Format("#{0,5:00000}: {1}", index + 1, stepReport.Name); tc.classname = stepReport.TestObjectPath; tc.time = stepReport.DurationSeconds; if (stepReport.Status == ReportStatus.Failed) { testsuiteTestcaseFailure failure = new testsuiteTestcaseFailure(); failure.message = stepReport.ErrorText; failure.type = string.Empty; tc.Item = failure; } return(tc); }
// For GUI test only private static testsuiteTestcase[] ConvertTestcases(ReportNodeEnumerator <XmlReport.GUITest.StepReport> steps, out int count, out int numOfFailures) { count = 0; numOfFailures = 0; List <testsuiteTestcase> list = new List <testsuiteTestcase>(); if (steps != null) { EnumerableReportNodes <XmlReport.GUITest.StepReport> stepReports = new EnumerableReportNodes <XmlReport.GUITest.StepReport>(steps); foreach (XmlReport.GUITest.StepReport step in stepReports) { testsuiteTestcase tc = GUITestReportConverter.ConvertTestcase(step, count); if (tc == null) { continue; } // update step name with the hierarchy full name tc.name = string.Format("#{0,7:0000000}: {1}", count + 1, GetHierarchyFullName(step)); list.Add(tc); if (step.Status == ReportStatus.Failed) { numOfFailures++; } count++; } } return(list.ToArray()); }
public static testsuiteTestcase ConvertTestcase(ActivityReport activityReport, int index) { testsuiteTestcase tc = new testsuiteTestcase(); tc.name = string.Format("#{0,5:00000}: {1}", index + 1, activityReport.Name); if (activityReport.ActivityExtensionData != null && activityReport.ActivityExtensionData.VTDType != null) { tc.classname = activityReport.ActivityExtensionData.VTDType.Value; } tc.time = activityReport.DurationSeconds; if (activityReport.Status == ReportStatus.Failed) { testsuiteTestcaseFailure failure = new testsuiteTestcaseFailure(); if (activityReport.CheckpointData != null && activityReport.CheckpointData.Checkpoints != null) { StringBuilder sb = new StringBuilder(); foreach (ExtData data in activityReport.CheckpointData.Checkpoints) { if (data.KnownVTDStatus == VTDStatus.Failure) { string actualValue = data.VTDActual != null ? data.VTDActual.Value : string.Empty; string expectedValue = data.VTDExpected != null ? data.VTDExpected.Value : string.Empty; string operation = data.VTDOperation != null ? data.VTDOperation.Value : string.Empty; if (string.IsNullOrEmpty(actualValue) && string.IsNullOrEmpty(expectedValue) && !string.IsNullOrEmpty(operation)) { // sample: [Checkpoint 1] Arguments[1]: Array - Fixed (compound) sb.AppendFormat(Properties.Resources.APITest_Checkpoint_CompoundValue, data.VTDName != null ? data.VTDName.Value : string.Empty, data.VTDXPath != null ? data.VTDXPath.Value : string.Empty, !string.IsNullOrEmpty(operation) ? operation : Properties.Resources.APITest_Checkpoint_NoOperation); } else { // sample: [Checkpoint 2] StatusCode: 404 (actual) = 200 (expected) sb.AppendFormat(Properties.Resources.APITest_Checkpoint_ActExp, data.VTDName != null ? data.VTDName.Value : string.Empty, data.VTDXPath != null ? data.VTDXPath.Value : string.Empty, !string.IsNullOrEmpty(actualValue) ? actualValue : Properties.Resources.APITest_Checkpoint_EmptyValue, !string.IsNullOrEmpty(operation) ? operation : Properties.Resources.APITest_Checkpoint_NoOperation, !string.IsNullOrEmpty(expectedValue) ? expectedValue : Properties.Resources.APITest_Checkpoint_EmptyValue); } sb.AppendLine(); } } failure.message = sb.ToString(); } if (string.IsNullOrWhiteSpace(failure.message)) { failure.message = activityReport.Description; } failure.type = string.Empty; tc.Item = failure; } return(tc); }
private static testsuiteTestcase ConvertTestcaseWithSmartIdentificationInfo(StepReport stepReport, int index) { SmartIdentificationInfoExtType sid = stepReport.SmartIdentification; if (sid == null) { throw new ArgumentNullException("stepReport.SmartIdentification"); } if (stepReport.Status == ReportStatus.Warning) { // a step with smart identification info and warning status can be ignored // since the next step is the official smart identification info report node _lastSkippedSIDStep = stepReport; return(null); } // a step with smart identification info int basicMatches = 0; if (sid.SIDBasicProperties != null) { basicMatches = sid.SIDBasicProperties.BasicMatch; } List <string> optList = new List <string>(); if (sid.SIDOptionalProperties != null) { foreach (SIDOptionalPropertyExtType property in sid.SIDOptionalProperties) { if (property.Matches > 0) { optList.Add(string.Format("{0}=\"{1}\"", property.Name, property.Value)); } } } string sidDesc = string.Format(Properties.Resources.GUITest_SID_Description, basicMatches, string.Join(", ", optList)); string sidName = stepReport.Node.Data.Name; testsuiteTestcase tc = new testsuiteTestcase(); tc.name = string.Format("#{0,5:00000}: {1} ({2})", index + 1, sidName, sidDesc); tc.classname = stepReport.TestObjectPath; tc.time = stepReport.DurationSeconds + (_lastSkippedSIDStep != null ? _lastSkippedSIDStep.DurationSeconds : 0); // clear last skipped SID step _lastSkippedSIDStep = null; return(tc); }
/// <summary> /// Converts the specified <see cref="BCStepReport"/> to the corresponding JUnit <see cref="testsuiteTestcase"/>. /// </summary> /// <param name="stepReport">The <see cref="BCStepReport"/> instance contains the data of a BPT business component step.</param> /// <param name="index">The index, starts from 0, to identify the order of the testcases.</param> /// <returns>The converted JUnit <see cref="testsuiteTestcase"/> instance.</returns> public static testsuiteTestcase ConvertTestcase(BCStepReport stepReport, int index) { testsuiteTestcase tc = new testsuiteTestcase(); tc.name = string.Format("#{0,5:00000}: {1}", index + 1, stepReport.Name); tc.classname = stepReport.TestObjectPath; tc.time = stepReport.DurationSeconds; if (stepReport.Status == ReportStatus.Failed) { testsuiteTestcaseFailure failure = new testsuiteTestcaseFailure(); failure.message = stepReport.ErrorText; failure.type = string.Empty; tc.Item = failure; } return(tc); }
// For BPT test only private static testsuiteTestcase[] ConvertTestcases(ReportNodeEnumerator <XmlReport.BPT.BusinessComponentReport> bcs, out int count, out int numOfFailures) { count = 0; numOfFailures = 0; List <testsuiteTestcase> list = new List <testsuiteTestcase>(); if (bcs != null) { EnumerableReportNodes <XmlReport.BPT.BusinessComponentReport> bcReports = new EnumerableReportNodes <XmlReport.BPT.BusinessComponentReport>(bcs); foreach (XmlReport.BPT.BusinessComponentReport bc in bcReports) { if (bc.AllBCStepsEnumerator != null) { EnumerableReportNodes <XmlReport.BPT.BCStepReport> steps = new EnumerableReportNodes <XmlReport.BPT.BCStepReport>(bc.AllBCStepsEnumerator); foreach (XmlReport.BPT.BCStepReport step in steps) { if (step.IsContext) { continue; } testsuiteTestcase tc = BPTReportConverter.ConvertTestcase(step, count); if (tc == null) { continue; } // update step name with the hierarchy full name tc.name = string.Format("#{0,7:0000000}: {1}", count + 1, GetHierarchyFullName(step, bc)); list.Add(tc); if (step.Status == ReportStatus.Failed) { numOfFailures++; } count++; } } } } return(list.ToArray()); }
// For API test only private static testsuiteTestcase[] ConvertTestcases(ReportNodeCollection <XmlReport.APITest.IterationReport> iterationReports, out int count, out int numOfFailures) { count = 0; numOfFailures = 0; List <testsuiteTestcase> list = new List <testsuiteTestcase>(); if (iterationReports != null) { int iterationNum = 0; foreach (XmlReport.APITest.IterationReport iteration in iterationReports) { iterationNum++; if (iteration.AllActivitiesEnumerator != null) { EnumerableReportNodes <XmlReport.APITest.ActivityReport> activities = new EnumerableReportNodes <XmlReport.APITest.ActivityReport>(iteration.AllActivitiesEnumerator); foreach (XmlReport.APITest.ActivityReport activity in activities) { testsuiteTestcase tc = APITestReportConverter.ConvertTestcase(activity, count); if (tc == null) { continue; } // update activity name with the hierarchy full name tc.name = string.Format("#{0,7:0000000}: {1}", count + 1, GetHierarchyFullName(activity, iterationNum)); list.Add(tc); if (activity.Status == ReportStatus.Failed) { numOfFailures++; } count++; } } } } return(list.ToArray()); }