internal static string Build(List <TestAttribute> Categories) { string source = ""; var list = new List <string>(); Categories .ToList() .ForEach(c => list.Add(c.GetName())); list.Sort(); var catParams = new string[] { ExtentFlag.GetPlaceHolder("testCategory"), ExtentFlag.GetPlaceHolder("testCategoryU") }; list.ForEach(c => { var catValues = new string[] { c, c.ToLower().Replace(" ", "") }; source += SourceBuilder.Build(CategoryFilterHtml.GetOptionSource(), catParams, catValues); }); return(source); }
private void UpdateCategoryList() { string catsAdded = ""; string c = ""; var placeholder = ""; for (int ix = categoryList.Categories.Count - 1; ix > -1; ix--) { c = categoryList.GetItem(ix); placeholder = ExtentFlag.GetPlaceHolder("categoryAdded" + c); if (extentSource.IndexOf(placeholder) == -1 && catsAdded.IndexOf(placeholder) == -1) { catsAdded += ExtentFlag.GetPlaceHolder("categoryAdded" + c); } else { categoryList.Categories.RemoveAt(ix); } } string source = CategoryOptionBuilder.Build(categoryList.Categories); if (source != "") { lock (sourcelock) { extentSource = SourceBuilder.Build(extentSource, new string[] { ExtentFlag.GetPlaceHolder("categoryListOptions"), ExtentFlag.GetPlaceHolder("categoryAdded") }, new string[] { source + ExtentFlag.GetPlaceHolder("categoryListOptions"), catsAdded + ExtentFlag.GetPlaceHolder("categoryAdded") }); } } }
public static string GetSource <T>(List <T> MediaList, string type) { string source = ""; if (MediaList == null || MediaList.Count == 0) { source = SourceBuilder.Build( ObjectEmbedHtml.GetFullWidth(), new string[] { ExtentFlag.GetPlaceHolder("objectViewValue"), ExtentFlag.GetPlaceHolder("objectViewNull") }, new string[] { "No media was embed for the tests in this report.", ExtentFlag.GetPlaceHolder("objectViewNull" + type) } ); return(source); } foreach (Object sc in MediaList) { source += ObjectEmbedHtml.GetColumn(); if (sc is ScreenCapture) { source = source.Replace(ExtentFlag.GetPlaceHolder("objectViewParam"), ((ScreenCapture)sc).TestName) .Replace(ExtentFlag.GetPlaceHolder("objectViewValue"), ((ScreenCapture)sc).Source); } if (sc is Screencast) { source = source.Replace(ExtentFlag.GetPlaceHolder("objectViewParam"), ((Screencast)sc).TestName) .Replace(ExtentFlag.GetPlaceHolder("objectViewValue"), ((Screencast)sc).Source); } } return(source); }
private void UpdateSuiteExecutionTime() { string[] flags = { ExtentFlag.GetPlaceHolder("suiteStartTime"), ExtentFlag.GetPlaceHolder("suiteEndTime") }; string[] values = { runInfo.StartedTime.ToString(), runInfo.EndedTime.ToString() }; lock (sourcelock) { extentSource = SourceBuilder.Build(extentSource, flags, values); } }
private void UpdateMediaList() { string mediaSource = MediaViewBuilder.GetSource(mediaList.ScreenCapture, "img"); string[] flags = new string[] { ExtentFlag.GetPlaceHolder("imagesView") }; string[] values = new string[] { mediaSource + ExtentFlag.GetPlaceHolder("imagesView") }; if (!(infoWrite >= 1 && values[0].IndexOf("No media") >= 0)) { lock (sourcelock) { extentSource = SourceBuilder.Build(extentSource, flags, values); if (mediaList.ScreenCapture.Count > 0) { try { string match = RegexMatcher.GetNthMatch(extentSource, ExtentFlag.GetPlaceHolder("objectViewNullImg") + ".*" + ExtentFlag.GetPlaceHolder("objectViewNullImg"), 0); extentSource = extentSource.Replace(match, ""); } catch { } } mediaList.ScreenCapture.Clear(); } } mediaSource = MediaViewBuilder.GetSource(mediaList.Screencast, "vid"); flags = new string[] { ExtentFlag.GetPlaceHolder("videosView") }; values = new string[] { mediaSource + ExtentFlag.GetPlaceHolder("videosView") }; if (!(infoWrite >= 1 && values[0].IndexOf("No media") >= 0)) { lock (sourcelock) { extentSource = SourceBuilder.Build(extentSource, flags, values); if (mediaList.Screencast.Count > 0) { try { string match = RegexMatcher.GetNthMatch(extentSource, ExtentFlag.GetPlaceHolder("objectViewNullVid") + ".*" + ExtentFlag.GetPlaceHolder("objectViewNullVid"), 0); extentSource = extentSource.Replace(match, ""); } catch { } } mediaList.Screencast.Clear(); } } infoWrite++; }
internal void WriteAllResources(List <ExtentTest> TestList, SystemInfo SystemInfo) { if (terminated) { throw new IOException("Stream closed"); } if (SystemInfo != null) { UpdateSystemInfo(SystemInfo.GetInfo()); } if (testSource == "") { return; } runInfo.EndedTime = DateTime.Now; UpdateCategoryList(); UpdateSuiteExecutionTime(); UpdateMediaList(); if (this.displayOrder == DisplayOrder.OldestFirst) { lock (sourcelock) { extentSource = SourceBuilder.Build(extentSource, new string[] { ExtentFlag.GetPlaceHolder("test"), ExtentFlag.GetPlaceHolder("quickTestSummary") }, new string[] { testSource + ExtentFlag.GetPlaceHolder("test"), quickSummarySource + ExtentFlag.GetPlaceHolder("quickTestSummary") }); } } else { lock (sourcelock) { extentSource = SourceBuilder.Build(extentSource, new string[] { ExtentFlag.GetPlaceHolder("test"), ExtentFlag.GetPlaceHolder("quickTestSummary") }, new string[] { ExtentFlag.GetPlaceHolder("test") + testSource, ExtentFlag.GetPlaceHolder("quickTestSummary") + quickSummarySource }); } } using (var file = new StreamWriter(filePath)) { TextWriter.Synchronized(file).WriteLine(extentSource); } testSource = ""; quickSummarySource = ""; }
public static string GetQuickSummary(Test test) { if (test.IsChildNode) { return(""); } string src = TestHtml.GetSourceQuickView(); var lc = new LogCounts().GetLogCounts(test); string[] flags = { ExtentFlag.GetPlaceHolder("testName"), ExtentFlag.GetPlaceHolder("testWarnings"), ExtentFlag.GetPlaceHolder("currentTestPassedCount"), ExtentFlag.GetPlaceHolder("currentTestFailedCount"), ExtentFlag.GetPlaceHolder("currentTestFatalCount"), ExtentFlag.GetPlaceHolder("currentTestErrorCount"), ExtentFlag.GetPlaceHolder("currentTestWarningCount"), ExtentFlag.GetPlaceHolder("currentTestInfoCount"), ExtentFlag.GetPlaceHolder("currentTestSkippedCount"), ExtentFlag.GetPlaceHolder("currentTestUnknownCount"), ExtentFlag.GetPlaceHolder("currentTestRunStatus"), ExtentFlag.GetPlaceHolder("currentTestRunStatusU") }; string[] values = { test.Name, TestHtml.GetWarningSource(test.InternalWarning), lc.Pass.ToString(), lc.Fail.ToString(), lc.Fatal.ToString(), lc.Error.ToString(), lc.Warning.ToString(), lc.Info.ToString(), lc.Skip.ToString(), lc.Unknown.ToString(), test.Status.ToString().ToLower(), test.Status.ToString().ToUpper() }; src = SourceBuilder.Build(src, flags, values); return(src); }
private void UpdateCategoryView(Test test) { string s = "", testSource = ""; string addedFlag = ""; string[] sourceKeys = { ExtentFlag.GetPlaceHolder("categoryViewName"), ExtentFlag.GetPlaceHolder("categoryViewTestDetails") }; string[] testKeys = { ExtentFlag.GetPlaceHolder("categoryViewTestRunTime"), ExtentFlag.GetPlaceHolder("categoryViewTestName"), ExtentFlag.GetPlaceHolder("categoryViewTestStatus") }; string[] testValues = { test.StartedTime.ToString(), test.Name, test.Status.ToString().ToLower() }; foreach (TestAttribute attr in test.CategoryList) { addedFlag = ExtentFlag.GetPlaceHolder("categoryViewTestDetails" + attr.GetName()); if (!extentSource.Contains(addedFlag)) { string[] sourceValues = { attr.GetName(), addedFlag }; s += SourceBuilder.Build(CategoryHtml.GetCategoryViewSource(), sourceKeys, sourceValues); testSource = SourceBuilder.Build(CategoryHtml.GetCategoryViewTestSource(), testKeys, testValues); s = SourceBuilder.Build(s, new string[] { addedFlag }, new string[] { testSource + addedFlag }); } else { testSource = SourceBuilder.Build(CategoryHtml.GetCategoryViewTestSource(), testKeys, testValues); lock (sourcelock) { extentSource = SourceBuilder.Build(extentSource, new string[] { addedFlag }, new string[] { testSource + addedFlag }); } } } lock (sourcelock) { extentSource = SourceBuilder.Build(extentSource, new string[] { ExtentFlag.GetPlaceHolder("extentCategoryDetails") }, new string[] { s + ExtentFlag.GetPlaceHolder("extentCategoryDetails") }); } }
private void UpdateSystemInfo(Dictionary <string, string> SystemInfo) { if (extentSource.IndexOf(ExtentFlag.GetPlaceHolder("systemInfoApplied")) > 0) { return; } if (SystemInfo.Count > 0) { string systemSource = SourceBuilder.GetSource(SystemInfo) + ExtentFlag.GetPlaceHolder("systemInfoApplied"); string[] flags = new string[] { ExtentFlag.GetPlaceHolder("systemInfoView") }; string[] values = new string[] { systemSource + ExtentFlag.GetPlaceHolder("systemInfoView") }; lock (sourcelock) { extentSource = SourceBuilder.Build(extentSource, flags, values); } } }
public static string buildOptions(List <string> Categories) { string source = ""; Categories.Sort(); var catFlags = new string[] { ExtentFlag.GetPlaceHolder("testCategory"), ExtentFlag.GetPlaceHolder("testCategoryU") }; Categories.ForEach(c => { var catValues = new string[] { c, c.ToLower().Replace(" ", "") }; source += SourceBuilder.Build(CategoryHtml.GetOptionSource(), catFlags, catValues); }); return(source); }
public static string GetSource(Test test) { if (test.IsChildNode) { return(""); } var testSource = TestHtml.GetSource(3); var stepSource = StepHtml.GetSource(2); if (test.Logs.Count > 0 && test.Logs[0].StepName != "") { testSource = TestHtml.GetSource(4); stepSource = StepHtml.GetSource(-1); } if (test.Description == "") { testSource = testSource.Replace(ExtentFlag.GetPlaceHolder("descVis"), "style='display:none;'"); } string[] testFlags = { ExtentFlag.GetPlaceHolder("testName"), ExtentFlag.GetPlaceHolder("testStatus"), ExtentFlag.GetPlaceHolder("testStartTime"), ExtentFlag.GetPlaceHolder("testEndTime"), ExtentFlag.GetPlaceHolder("testTimeTaken"), ExtentFlag.GetPlaceHolder("testDescription"), ExtentFlag.GetPlaceHolder("descVis"), ExtentFlag.GetPlaceHolder("category"), ExtentFlag.GetPlaceHolder("testWarnings") }; string[] testValues = { test.Name, test.Status.ToString().ToLower(), test.StartedTime.ToString(), test.EndedTime.ToString(), (test.EndedTime - test.StartedTime).Minutes + "m " + (test.EndedTime - test.StartedTime).Seconds + "s", test.Description, "", "", TestHtml.GetWarningSource(test.InternalWarning) }; testSource = SourceBuilder.Build(testSource, testFlags, testValues); testFlags = new string[] { ExtentFlag.GetPlaceHolder("testCategory"), ExtentFlag.GetPlaceHolder("category") }; test.CategoryList.ForEach(attr => { testValues = new string[] { TestHtml.GetCategorySource() + ExtentFlag.GetPlaceHolder("testCategory"), attr.GetName() }; testSource = SourceBuilder.Build(testSource, testFlags, testValues); }); var stepSrc = StepHtml.GetSource(2); string[] stepFlags = { ExtentFlag.GetPlaceHolder("step"), ExtentFlag.GetPlaceHolder("timeStamp"), ExtentFlag.GetPlaceHolder("stepStatusU"), ExtentFlag.GetPlaceHolder("stepStatus"), ExtentFlag.GetPlaceHolder("statusIcon"), ExtentFlag.GetPlaceHolder("stepName"), ExtentFlag.GetPlaceHolder("details") }; string[] stepValues; if (test.Logs.Count > 0) { if (test.Logs[0].StepName != "") { stepSrc = StepHtml.GetSource(3); } test.Logs.ForEach(log => { stepValues = new string[] { stepSrc + ExtentFlag.GetPlaceHolder("step"), log.Timestamp.ToShortTimeString(), log.LogStatus.ToString().ToUpper(), log.LogStatus.ToString().ToLower(), Icon.GetIcon(log.LogStatus), log.StepName, log.Details }; testSource = SourceBuilder.Build(testSource, stepFlags, stepValues); }); } testSource = testSource.Replace(ExtentFlag.GetPlaceHolder("step"), ""); testSource = AddChildTests(test, testSource, 1); return(testSource); }
private static string AddChildTests(Test test, String testSource, int nodeLevel) { string nodeSource, stepSrc = ""; string[] testValues, stepValues; string[] testFlags = { ExtentFlag.GetPlaceHolder("nodeList"), ExtentFlag.GetPlaceHolder("nodeName"), ExtentFlag.GetPlaceHolder("nodeStartTime"), ExtentFlag.GetPlaceHolder("nodeEndTime"), ExtentFlag.GetPlaceHolder("nodeTimeTaken"), ExtentFlag.GetPlaceHolder("nodeLevel") }; string[] stepFlags = { ExtentFlag.GetPlaceHolder("nodeStep"), ExtentFlag.GetPlaceHolder("timeStamp"), ExtentFlag.GetPlaceHolder("stepStatusU"), ExtentFlag.GetPlaceHolder("stepStatus"), ExtentFlag.GetPlaceHolder("statusIcon"), ExtentFlag.GetPlaceHolder("stepName"), ExtentFlag.GetPlaceHolder("details") }; test.NodeList.ForEach(node => { nodeSource = TestHtml.GetNodeSource(3); if (node.Logs.Count > 0 && node.Logs[0].StepName != "") { nodeSource = TestHtml.GetNodeSource(4); } testValues = new string[] { nodeSource + ExtentFlag.GetPlaceHolder("nodeList"), node.Name, node.StartedTime.ToString(), node.EndedTime.ToString(), (node.EndedTime - node.StartedTime).Minutes + "m " + (node.EndedTime - node.StartedTime).Seconds + "s", "node-" + nodeLevel + "x" }; testSource = SourceBuilder.Build(testSource, testFlags, testValues); if (node.Logs.Count > 0) { testSource = testSource.Replace(ExtentFlag.GetPlaceHolder("nodeStatus"), node.Status.ToString().ToLower()); stepSrc = StepHtml.GetSource(2); if (node.Logs[0].StepName != "") { stepSrc = StepHtml.GetSource(3); } node.Logs.ForEach(log => { stepValues = new string[] { stepSrc + ExtentFlag.GetPlaceHolder("nodeStep"), log.Timestamp.ToShortTimeString(), log.LogStatus.ToString().ToUpper(), log.LogStatus.ToString().ToLower(), Icon.GetIcon(log.LogStatus), log.StepName, log.Details }; testSource = SourceBuilder.Build(testSource, stepFlags, stepValues); }); } testSource = SourceBuilder.Build(testSource, new string[] { ExtentFlag.GetPlaceHolder("step"), ExtentFlag.GetPlaceHolder("nodeStep") }, new string[] { "", "" }); if (node.HasChildNodes) { testSource = AddChildTests(node, testSource, ++nodeLevel); --nodeLevel; } }); return(testSource); }