static TestReportBase ReadInputInternal(string path, ref ExitCode.ExitCodeData errorCode) { string xmlReportFile = path; if (!File.Exists(xmlReportFile)) { // the input path could be a folder, try to detect it string dir = xmlReportFile; xmlReportFile = Path.Combine(dir, XMLReport_File); if (!File.Exists(xmlReportFile)) { // still not find, may be under "Report" sub folder? try it xmlReportFile = Path.Combine(dir, XMLReport_SubDir_Report, XMLReport_File); if (!File.Exists(xmlReportFile)) { OutputWriter.WriteLine(Properties.Resources.ErrMsg_CannotFindXmlReportFile + " " + path); errorCode = ExitCode.FileNotFound; return(null); } } } // load XML from file with the specified XML schema ResultsType root = XmlReportUtilities.LoadXmlFileBySchemaType <ResultsType>(xmlReportFile); if (root == null) { errorCode = ExitCode.CannotReadFile; return(null); } // try to load the XML data as a GUI test report GUITestReport guiReport = new GUITestReport(root, xmlReportFile); if (guiReport.TryParse()) { return(guiReport); } // try to load as API test report APITestReport apiReport = new APITestReport(root, xmlReportFile); if (apiReport.TryParse()) { return(apiReport); } // try to load as BP test report BPTReport bptReport = new BPTReport(root, xmlReportFile); if (bptReport.TryParse()) { return(bptReport); } OutputWriter.WriteLine(Properties.Resources.ErrMsg_Input_InvalidFirstReportNode + " " + path); errorCode = ExitCode.InvalidInput; return(null); }
public override bool TryParse() { if (!base.TryParse()) { return(false); } // update the duration for the last step TestReport ownerTest = (TestReport)OwnerTest; ActivityReport lastActivity = ownerTest.LastActivity; if (lastActivity != null) { TimeSpan ts = StartTime - lastActivity.StartTime; lastActivity.DurationSeconds = (decimal)ts.TotalSeconds; } ownerTest.LastActivity = this; // activity extended data string parentDir = Path.GetDirectoryName(ownerTest.ReportFile); if (!string.IsNullOrWhiteSpace(Node.Data.Extension.BottomFilePath)) { string bottomFilePath = Path.Combine(parentDir, Node.Data.Extension.BottomFilePath); ActivityExtensionData = XmlReportUtilities.LoadXmlFileBySchemaType <ActivityExtData>(bottomFilePath); } // activity checkpoint extended data if (Node.Data.Extension.MergedSTCheckpointData != null && !string.IsNullOrWhiteSpace(Node.Data.Extension.MergedSTCheckpointData.BottomFilePath)) { string bottomFilePath = Path.Combine(parentDir, Node.Data.Extension.MergedSTCheckpointData.BottomFilePath); CheckpointData = XmlReportUtilities.LoadXmlFileBySchemaType <CheckpointExtData>(bottomFilePath); } // sub activities SubActivities.Clear(); ReportNodeType[] childNodes = Node.ReportNode; if (childNodes != null) { foreach (ReportNodeType node in childNodes) { // sub-activities ActivityReport subActivity = SubActivities.TryParseAndAdd(node, this.Node); if (subActivity != null) { AllActivitiesEnumerator.Add(subActivity); AllActivitiesEnumerator.Merge(subActivity.AllActivitiesEnumerator); continue; } } } return(true); }