extent-framework / extentreports-csharp

Extent Reporting Library, .NET
http://extentreports.com
Apache License 2.0
50 stars 39 forks source link

exception while using extentreport.flush() #60

Closed anunay1 closed 4 years ago

anunay1 commented 5 years ago

Hi,

I am facing a weird issue, so far the extent report was working fine, but all of a sudden it has stopped working, and started throwing RazorEngine excetption. the exception is shown below:

TestCleanup method threw exception. RazorEngine.Templating.TemplateCompilationException: RazorEngine.Templating.TemplateCompilationException: Errors while compiling a Template. Please try the following to solve the situation: * If the problem is about missing/invalid references or multiple defines either try to load the missing references manually (in the compiling appdomain!) or Specify your references manually by providing your own IReferenceResolver implementation. See https://antaris.github.io/RazorEngine/ReferenceResolver.html for details. Currently all references have to be available as files! * If you get 'class' does not contain a definition for 'member': try another modelType (for example 'null' to make the model dynamic). NOTE: You CANNOT use typeof(dynamic) to make the model dynamic! Or try to use static instead of anonymous/dynamic types. More details about the error: - error: (0, 0) The type 'System.Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Temporary files of the compilation can be found in (please delete the folder): C:\Users\INANTHA3\AppData\Local\Temp\RazorEngine_no5cu31q.32z The template we tried to compile is: ------------- START ----------- @using AventStack.ExtentReports @using RazorEngine @using RazorEngine.Templating <!DOCTYPE html> <html> @Include("Head") <script type="text/javascript"> /*! json-tree - v0.2.2 - 2017-09-25, MIT LICENSE */ var JSONTree=function(){var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;"},t=0,r=0;this.create=function(n,t){return r+=1,N(u(n,0,!1),{class:"jstValue"})};var e=function(t){return t.replace(/[&<>'"]/g,function(t){return n[t]})},s=function(){return r+"_"+t++},u=function(n,t,r){if(null===n)return f(r?t:0);switch(typeof n){case"boolean":return l(n,r?t:0);case"number":return i(n,r?t:0);case"string":return o(n,r?t:0);default:return n instanceof Array?a(n,t,r):c(n,t,r)}},c=function(n,t,r){var e=s(),u=Object.keys(n).map(function(r){return j(r,n[r],t+1,!0)}).join(m()),c=[g("{",r?t:0,e),N(u,{id:e}),p("}",t)].join("\n");return N(c,{})},a=function(n,t,r){var e=s(),c=n.map(function(n){return u(n,t+1,!0)}).join(m());return[g("[",r?t:0,e),N(c,{id:e}),p("]",t)].join("\n")},o=function(n,t){var r=e(JSON.stringify(n));return N(v(r,t),{class:"jstStr"})},i=function(n,t){return N(v(n,t),{class:"jstNum"})},l=function(n,t){return N(v(n,t),{class:"jstBool"})},f=function(n){return N(v("null",n),{class:"jstNull"})},j=function(n,t,r){var s=v(e(JSON.stringify(n))+": ",r),c=N(u(t,r,!1),{});return N(s+c,{class:"jstProperty"})},m=function(){return N(",\n",{class:"jstComma"})},N=function(n,t){return d("span",t,n)},d=function(n,t,r){return"<"+n+Object.keys(t).map(function(n){return" "+n+'="'+t[n]+'"'}).join("")+">"+r+"</"+n+">"},g=function(n,t,r){return N(v(n,t),{class:"jstBracket"})+N("",{class:"jstFold",onclick:"JSONTree.toggle('"+r+"')"})};this.toggle=function(n){var t=document.getElementById(n),r=t.parentNode,e=t.previousElementSibling;""===t.className?(t.className="jstHiddenBlock",r.className="jstFolded",e.className="jstExpand"):(t.className="",r.className="",e.className="jstFold")};var p=function(n,t){return N(v(n,t),{})},v=function(n,t){return Array(2*t+1).join(" ")+n};return this}(); </script> <body class="test-view @Model.MasterConfig.GetValue("theme")"> <div class="app"> <div class="layout"> @Include("Navbar") @Include("Sidenav") <div class="page-container"> <div class="main-content"> <div class="avt-container row"> <div class="test-list"> <div class="test-list-tools"> <ul class="tools pull-left"> <li> <a href=""> <span>Tests</span> </a> </li> </ul> <ul class="tools text-right"> <li> <div class="dropdown"> <a href="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-warning"></i> </a> <div id="status-toggle" class="dropdown-menu"> @if (Model.ContainsStatus(Status.Pass)) {<a status="pass" class="dropdown-item" href="#"><span>Pass</span><span class="status success pull-right"></span></a>} @if (Model.ContainsStatus(Status.Fail)) {<a status="fail" class="dropdown-item" href="#"><span>Fail</span><span class="status danger pull-right"></span></a>} @if (Model.ContainsStatus(Status.Fatal)) {<a status="fatal" class="dropdown-item" href="#"><span>Fatal</span><span class="status danger pull-right"></span></a>} @if (Model.ContainsStatus(Status.Error)) {<a status="error" class="dropdown-item" href="#"><span>Error</span><span class="status warning pull-right"></span></a>} @if (Model.ContainsStatus(Status.Warning)) {<a status="warning" class="dropdown-item" href="#"><span>Warning</span><span class="status warning pull-right"></span></a>} @if (Model.ContainsStatus(Status.Skip)) {<a status="skip" class="dropdown-item" href="#"><span>Skip</span><span class="status warning pull-right"></span></a>} <div class="dropdown-divider"></div> <a status="clear" class="dropdown-item" href="#"><span>Clear</span><span class="pull-right"><i class="fa fa-close"></i></span></a> </div> </div> </li> @if (Model.AuthorContext.Context.Count > 0) { <li> <div class="dropdown"> <a href="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-user"></i> </a> <div id="author-toggle" class="dropdown-menu"> @foreach (var author in Model.AuthorContext.Context) { <a class="dropdown-item" href="#">@author.Name</a> } </div> </div> </li> } @if (Model.CategoryContext.Context.Count > 0) { <li> <div class="dropdown"> <a href="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-tag"></i> </a> <div id="tag-toggle" class="dropdown-menu"> @foreach (var category in Model.CategoryContext.Context) { <a class="dropdown-item" href="#">@category.Name</a> } </div> </div> </li> } @if (Model.DeviceContext.Context.Count > 0) { <li> <div class="dropdown"> <a href="dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-tablet"></i> </a> <div id="device-toggle" class="dropdown-menu"> @foreach (var device in Model.DeviceContext.Context) { <a class="dropdown-item" href="#">@device.Name</a> } </div> </div> </li> } </ul> </div> <div class="avt-wrapper scrollable"> <ul id="test-list-item" class="test-list-item"> @foreach (var test in Model.TestList) { string authors = "", devices = "", tags = ""; foreach (var author in test.AuthorContext.All()) { authors += author.Name + " "; } foreach (var device in test.DeviceContext.All()) { devices += device.Name + " "; } foreach (var tag in test.CategoryContext.All()) { tags += tag.Name + " "; } <li class="test" status="@test.Status.ToString().ToLower()" author="@authors.Trim()" device="@devices.Trim()" tag="@tags.Trim()"> <div class="status-avatar @test.Status.ToString().ToLower()-bg"> @test.Status.ToString().Replace("ing","") </div> <div> <div class="test-detail"> <p class="name">@test.Name</p> <p class="duration">@test.RunDuration.ToString("''h'h:'m'm:'s's+'fff'ms'")</p> <span class="datetime">@test.StartTime.ToString("HH:mm:ss tt")</span> </div> </div> <div class="test-content-detail"> <div class="detail-head"> <div class="p-v-10 d-inline-block"> <div class="info"> <h4 class="test-status text-@test.Status.ToString().ToLower()">@test.Name</h4> <span class='badge badge-success'>@test.StartTime</span> <span class='badge badge-danger'>@test.EndTime</span> <span class='badge badge-default'>@test.RunDuration.ToString("''h'h:'m'm:'s's+'fff'ms'")</span> </div> @if (test.HasAttributes) { <div class="m-t-15"> @Include("Attributes", test) </div> } @if (!string.IsNullOrEmpty(test.Description)) { <div class="m-t-10 m-l-5"> @test.Description </div> } </div> <!-- <ul class="tools"> <li>Fri 8:40 AM</li> <li class="d-none d-md-inline-block"> <a href=""> <i class="fa fa-reply"></i> </a> </li> </ul> --> </div> <div class="detail-body m-t-20"> @if (test.HasLog) { @Include("Log", test) } </div> @if (test.HasScreenCapture) { <div class="detail-foot"> <ul class="attachments"> @foreach (var sc in test.ScreenCaptureContext.All()) { <li> <a href="@sc.ScreenCapturePath" data-featherlight="image"> <div class="file-icon"> <i class="fa fa-file-image-o"></i> </div> <div class="file-info"> @if (sc.IsBase64) { <span class="file-name">base64</span> <span class="file-size">0Kb</span> } else { <span class="file-name">@sc.Name</span> <span class="file-size"> @(sc.FileSize)Kb</span> } </div> </a> </li> } </ul> </div> } @if (test.HasChildren) { @Include("RecurseNodes", test) } </div> </li> } </ul> </div> </div> <div class="test-content scrollable"></div> </div> </div> </div> </div> </div> @Include("Scripts") </body> </html> ------------- END ----------- The generated source code is: ------------- START ----------- //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ namespace CompiledRazorTemplates.Dynamic { using System; using System.Collections.Generic; using System.Linq; using AventStack.ExtentReports; using RazorEngine; using RazorEngine.Templating; public class RazorEngine_6d19ff0cbfaa471eae6bf7ddbed4d1e7 : RazorEngine.Templating.TemplateBase<AventStack.ExtentReports.Reporter.ExtentHtmlReporter> { public RazorEngine_6d19ff0cbfaa471eae6bf7ddbed4d1e7() { } public override void Execute() { WriteLiteral("\r\n<!DOCTYPE html>\r\n<html>\r\n"); Write(Include("Head")); WriteLiteral("\r\n<script"); WriteLiteral(" type=\"text/javascript\""); WriteLiteral(">\r\n\t/*! json-tree - v0.2.2 - 2017-09-25, MIT LICENSE */\r\n\tvar JSONTree=function()" + "{var n={\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\",\'\"\':\"&quot;\",\"\'\":\"&#x27;\",\"/\":\"&#x2F;\"" + "},t=0,r=0;this.create=function(n,t){return r+=1,N(u(n,0,!1),{class:\"jstValue\"})}" + ";var e=function(t){return t.replace(/[&<>\'\"]/g,function(t){return n[t]})},s=func" + "tion(){return r+\"_\"+t++},u=function(n,t,r){if(null===n)return f(r?t:0);switch(ty" + "peof n){case\"boolean\":return l(n,r?t:0);case\"number\":return i(n,r?t:0);case\"stri" + "ng\":return o(n,r?t:0);default:return n instanceof Array?a(n,t,r):c(n,t,r)}},c=fu" + "nction(n,t,r){var e=s(),u=Object.keys(n).map(function(r){return j(r,n[r],t+1,!0)" + "}).join(m()),c=[g(\"{\",r?t:0,e),N(u,{id:e}),p(\"}\",t)].join(\"\\n\");return N(c,{})}," + "a=function(n,t,r){var e=s(),c=n.map(function(n){return u(n,t+1,!0)}).join(m());r" + "eturn[g(\"[\",r?t:0,e),N(c,{id:e}),p(\"]\",t)].join(\"\\n\")},o=function(n,t){var r=e(J" + "SON.stringify(n));return N(v(r,t),{class:\"jstStr\"})},i=function(n,t){return N(v(" + "n,t),{class:\"jstNum\"})},l=function(n,t){return N(v(n,t),{class:\"jstBool\"})},f=fu" + "nction(n){return N(v(\"null\",n),{class:\"jstNull\"})},j=function(n,t,r){var s=v(e(J" + "SON.stringify(n))+\": \",r),c=N(u(t,r,!1),{});return N(s+c,{class:\"jstProperty\"})}" + ",m=function(){return N(\",\\n\",{class:\"jstComma\"})},N=function(n,t){return d(\"span" + "\",t,n)},d=function(n,t,r){return\"<\"+n+Object.keys(t).map(function(n){return\" \"+n" + "+\'=\"\'+t[n]+\'\"\'}).join(\"\")+\">\"+r+\"</\"+n+\">\"},g=function(n,t,r){return N(v(n,t),{c" + "lass:\"jstBracket\"})+N(\"\",{class:\"jstFold\",onclick:\"JSONTree.toggle(\'\"+r+\"\')\"})};" + "this.toggle=function(n){var t=document.getElementById(n),r=t.parentNode,e=t.prev" + "iousElementSibling;\"\"===t.className?(t.className=\"jstHiddenBlock\",r.className=\"j" + "stFolded\",e.className=\"jstExpand\"):(t.className=\"\",r.className=\"\",e.className=\"j" + "stFold\")};var p=function(n,t){return N(v(n,t),{})},v=function(n,t){return Array(" + "2*t+1).join(\" \")+n};return this}();\r\n</script>\r\n<body"); WriteAttribute("class", Tuple.Create(" class=\"", 2053), Tuple.Create("\"", 2108) , Tuple.Create(Tuple.Create("", 2061), Tuple.Create("test-view", 2061), true) , Tuple.Create(Tuple.Create(" ", 2070), Tuple.Create<System.Object, System.Int32>(Model.MasterConfig.GetValue("theme") , 2071), false) ); WriteLiteral(">\r\n <div"); WriteLiteral(" class=\"app\""); WriteLiteral(">\r\n <div"); WriteLiteral(" class=\"layout\""); WriteLiteral(">\r\n"); WriteLiteral(" "); Write(Include("Navbar")); WriteLiteral("\r\n"); WriteLiteral(" "); Write(Include("Sidenav")); WriteLiteral("\r\n <div"); WriteLiteral(" class=\"page-container\""); WriteLiteral(">\r\n <div"); WriteLiteral(" class=\"main-content\""); WriteLiteral(">\r\n <div"); WriteLiteral(" class=\"avt-container row\""); WriteLiteral(">\r\n <div"); WriteLiteral(" class=\"test-list\""); WriteLiteral(">\r\n <div"); WriteLiteral(" class=\"test-list-tools\""); WriteLiteral(">\r\n <ul"); WriteLiteral(" class=\"tools pull-left\""); WriteLiteral(">\r\n <li>\r\n " + " <a"); WriteLiteral(" href=\"\""); WriteLiteral(">\r\n <span>Tests</span>\r\n " + " </a>\r\n </li> \r\n " + " </ul>\r\n <ul"); WriteLiteral(" class=\"tools text-right\""); WriteLiteral(">\r\n <li>\r\n " + " <div"); WriteLiteral(" class=\"dropdown\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t<a"); WriteLiteral(" href=\"dropdown-toggle\""); WriteLiteral(" data-toggle=\"dropdown\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t\t<i"); WriteLiteral(" class=\"fa fa-warning\""); WriteLiteral("></i>\r\n\t\t\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" id=\"status-toggle\""); WriteLiteral(" class=\"dropdown-menu\""); WriteLiteral(">\r\n"); if (Model.ContainsStatus(Status.Pass)) { WriteLiteral("<a"); WriteLiteral(" status=\"pass\""); WriteLiteral(" class=\"dropdown-item\""); WriteLiteral(" href=\"#\""); WriteLiteral("><span>Pass</span><span"); WriteLiteral(" class=\"status success pull-right\""); WriteLiteral("></span></a>"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t"); if (Model.ContainsStatus(Status.Fail)) { WriteLiteral("<a"); WriteLiteral(" status=\"fail\""); WriteLiteral(" class=\"dropdown-item\""); WriteLiteral(" href=\"#\""); WriteLiteral("><span>Fail</span><span"); WriteLiteral(" class=\"status danger pull-right\""); WriteLiteral("></span></a>"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t"); if (Model.ContainsStatus(Status.Fatal)) { WriteLiteral("<a"); WriteLiteral(" status=\"fatal\""); WriteLiteral(" class=\"dropdown-item\""); WriteLiteral(" href=\"#\""); WriteLiteral("><span>Fatal</span><span"); WriteLiteral(" class=\"status danger pull-right\""); WriteLiteral("></span></a>"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t"); if (Model.ContainsStatus(Status.Error)) { WriteLiteral("<a"); WriteLiteral(" status=\"error\""); WriteLiteral(" class=\"dropdown-item\""); WriteLiteral(" href=\"#\""); WriteLiteral("><span>Error</span><span"); WriteLiteral(" class=\"status warning pull-right\""); WriteLiteral("></span></a>"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t"); if (Model.ContainsStatus(Status.Warning)) { WriteLiteral("<a"); WriteLiteral(" status=\"warning\""); WriteLiteral(" class=\"dropdown-item\""); WriteLiteral(" href=\"#\""); WriteLiteral("><span>Warning</span><span"); WriteLiteral(" class=\"status warning pull-right\""); WriteLiteral("></span></a>"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t"); if (Model.ContainsStatus(Status.Skip)) { WriteLiteral("<a"); WriteLiteral(" status=\"skip\""); WriteLiteral(" class=\"dropdown-item\""); WriteLiteral(" href=\"#\""); WriteLiteral("><span>Skip</span><span"); WriteLiteral(" class=\"status warning pull-right\""); WriteLiteral("></span></a>"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" class=\"dropdown-divider\""); WriteLiteral("></div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<a"); WriteLiteral(" status=\"clear\""); WriteLiteral(" class=\"dropdown-item\""); WriteLiteral(" href=\"#\""); WriteLiteral("><span>Clear</span><span"); WriteLiteral(" class=\"pull-right\""); WriteLiteral("><i"); WriteLiteral(" class=\"fa fa-close\""); WriteLiteral("></i></span></a>\r\n\t\t\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t\t\t</div>\r\n " + " </li>\r\n"); if (Model.AuthorContext.Context.Count > 0) { WriteLiteral(" <li>\r\n " + " <div"); WriteLiteral(" class=\"dropdown\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t<a"); WriteLiteral(" href=\"dropdown-toggle\""); WriteLiteral(" data-toggle=\"dropdown\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t\t<i"); WriteLiteral(" class=\"fa fa-user\""); WriteLiteral("></i>\r\n\t\t\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" id=\"author-toggle\""); WriteLiteral(" class=\"dropdown-menu\""); WriteLiteral(">\r\n"); foreach (var author in Model.AuthorContext.Context) { WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t\t<a"); WriteLiteral(" class=\"dropdown-item\""); WriteLiteral(" href=\"#\""); WriteLiteral(">"); Write(author.Name); WriteLiteral("</a>\r\n"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t\t\t</div>\r\n </li>\r\n"); } WriteLiteral("\t\t\t\t\t\t\t\t\t"); if (Model.CategoryContext.Context.Count > 0) { WriteLiteral("\t\t\t\t\t\t\t\t\t<li>\r\n <div"); WriteLiteral(" class=\"dropdown\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t<a"); WriteLiteral(" href=\"dropdown-toggle\""); WriteLiteral(" data-toggle=\"dropdown\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t\t<i"); WriteLiteral(" class=\"fa fa-tag\""); WriteLiteral("></i>\r\n\t\t\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" id=\"tag-toggle\""); WriteLiteral(" class=\"dropdown-menu\""); WriteLiteral(">\r\n"); foreach (var category in Model.CategoryContext.Context) { WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t\t<a"); WriteLiteral(" class=\"dropdown-item\""); WriteLiteral(" href=\"#\""); WriteLiteral(">"); Write(category.Name); WriteLiteral("</a>\r\n"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t\t\t</div>\r\n </li>\r\n"); } WriteLiteral("\t\t\t\t\t\t\t\t\t"); if (Model.DeviceContext.Context.Count > 0) { WriteLiteral("\t\t\t\t\t\t\t\t\t<li>\r\n\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" class=\"dropdown\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t<a"); WriteLiteral(" href=\"dropdown-toggle\""); WriteLiteral(" data-toggle=\"dropdown\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t\t<i"); WriteLiteral(" class=\"fa fa-tablet\""); WriteLiteral("></i>\r\n\t\t\t\t\t\t\t\t\t\t\t</a>\r\n <div"); WriteLiteral(" id=\"device-toggle\""); WriteLiteral(" class=\"dropdown-menu\""); WriteLiteral(">\r\n"); foreach (var device in Model.DeviceContext.Context) { WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t\t<a"); WriteLiteral(" class=\"dropdown-item\""); WriteLiteral(" href=\"#\""); WriteLiteral(">"); Write(device.Name); WriteLiteral("</a>\r\n"); } WriteLiteral(" </div>\r\n " + " </div>\r\n </li>\r\n"); } WriteLiteral(" </ul>\r\n </div>\r\n " + " <div"); WriteLiteral(" class=\"avt-wrapper scrollable\""); WriteLiteral(">\r\n <ul"); WriteLiteral(" id=\"test-list-item\""); WriteLiteral(" class=\"test-list-item\""); WriteLiteral(">\r\n"); foreach (var test in Model.TestList) { string authors = "", devices = "", tags = ""; foreach (var author in test.AuthorContext.All()) { authors += author.Name + " "; } foreach (var device in test.DeviceContext.All()) { devices += device.Name + " "; } foreach (var tag in test.CategoryContext.All()) { tags += tag.Name + " "; } WriteLiteral(" <li"); WriteLiteral(" class=\"test\""); WriteAttribute("status", Tuple.Create(" status=\"", 7141), Tuple.Create("\"", 7183) , Tuple.Create(Tuple.Create("", 7150), Tuple.Create<System.Object, System.Int32>(test.Status.ToString().ToLower() , 7150), false) ); WriteAttribute("author", Tuple.Create(" author=\"", 7184), Tuple.Create("\"", 7208) , Tuple.Create(Tuple.Create("", 7193), Tuple.Create<System.Object, System.Int32>(authors.Trim() , 7193), false) ); WriteAttribute("device", Tuple.Create(" device=\"", 7209), Tuple.Create("\"", 7233) , Tuple.Create(Tuple.Create("", 7218), Tuple.Create<System.Object, System.Int32>(devices.Trim() , 7218), false) ); WriteAttribute("tag", Tuple.Create(" tag=\"", 7234), Tuple.Create("\"", 7252) , Tuple.Create(Tuple.Create("", 7240), Tuple.Create<System.Object, System.Int32>(tags.Trim() , 7240), false) ); WriteLiteral(">\r\n <div"); WriteAttribute("class", Tuple.Create(" class=\"", 7300), Tuple.Create("\"", 7358) , Tuple.Create(Tuple.Create("", 7308), Tuple.Create("status-avatar", 7308), true) , Tuple.Create(Tuple.Create(" ", 7321), Tuple.Create<System.Object, System.Int32>(test.Status.ToString().ToLower() , 7322), false) , Tuple.Create(Tuple.Create("", 7355), Tuple.Create("-bg", 7355), true) ); WriteLiteral(">\r\n"); WriteLiteral(" "); Write(test.Status.ToString().Replace("ing","")); WriteLiteral("\r\n </div> \r\n " + " <div>\r\n <div"); WriteLiteral(" class=\"test-detail\""); WriteLiteral("> \r\n <p"); WriteLiteral(" class=\"name\""); WriteLiteral(">"); Write(test.Name); WriteLiteral("</p> \r\n <p"); WriteLiteral(" class=\"duration\""); WriteLiteral(">"); Write(test.RunDuration.ToString("''h'h:'m'm:'s's+'fff'ms'")); WriteLiteral("</p> \r\n <span"); WriteLiteral(" class=\"datetime\""); WriteLiteral(">"); Write(test.StartTime.ToString("HH:mm:ss tt")); WriteLiteral("</span>\r\n </div>\r\n " + " </div>\r\n\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" class=\"test-content-detail\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" class=\"detail-head\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" class=\"p-v-10 d-inline-block\""); WriteLiteral(">\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" class=\"info\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<h4"); WriteAttribute("class", Tuple.Create(" class=\"", 8229), Tuple.Create("\"", 8287) , Tuple.Create(Tuple.Create("", 8237), Tuple.Create("test-status", 8237), true) , Tuple.Create(Tuple.Create(" ", 8248), Tuple.Create("text-", 8249), true) , Tuple.Create(Tuple.Create("", 8254), Tuple.Create<System.Object, System.Int32>(test.Status.ToString().ToLower() , 8254), false) ); WriteLiteral(">"); Write(test.Name); WriteLiteral("</h4>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span"); WriteLiteral(" class=\'badge badge-success\'"); WriteLiteral(">"); Write(test.StartTime); WriteLiteral("</span>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span"); WriteLiteral(" class=\'badge badge-danger\'"); WriteLiteral(">"); Write(test.EndTime); WriteLiteral("</span>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span"); WriteLiteral(" class=\'badge badge-default\'"); WriteLiteral(">"); Write(test.RunDuration.ToString("''h'h:'m'm:'s's+'fff'ms'")); WriteLiteral("</span>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\r\n"); if (test.HasAttributes) { WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" class=\"m-t-15\""); WriteLiteral(">\r\n"); WriteLiteral("\t\t \t\t"); Write(Include("Attributes", test)); WriteLiteral("\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\r\n"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t\t"); if (!string.IsNullOrEmpty(test.Description)) { WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" class=\"m-t-10 m-l-5\""); WriteLiteral(">\r\n"); WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t\t\t"); Write(test.Description); WriteLiteral("\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\r\n"); } WriteLiteral(@" </div> <!-- <ul class=""tools""> <li>Fri 8:40 AM</li> <li class=""d-none d-md-inline-block""> <a href=""""> <i class=""fa fa-reply""></i> </a> </li> </ul> --> </div> <div"); WriteLiteral(" class=\"detail-body m-t-20\""); WriteLiteral(">\r\n"); if (test.HasLog) { Write(Include("Log", test)); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t</div> \r\n"); if (test.HasScreenCapture) { WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" class=\"detail-foot\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t\t<ul"); WriteLiteral(" class=\"attachments\""); WriteLiteral(">\r\n"); foreach (var sc in test.ScreenCaptureContext.All()) { WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t\t<li>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a"); WriteAttribute("href", Tuple.Create(" href=\"", 9705), Tuple.Create("\"", 9733) , Tuple.Create(Tuple.Create("", 9712), Tuple.Create<System.Object, System.Int32>(sc.ScreenCapturePath , 9712), false) ); WriteLiteral(" data-featherlight=\"image\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" class=\"file-icon\""); WriteLiteral(">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i"); WriteLiteral(" class=\"fa fa-file-image-o\""); WriteLiteral("></i> \r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div"); WriteLiteral(" class=\"file-info\""); WriteLiteral(">\r\n"); if (sc.IsBase64) { WriteLiteral("\t\t \t\t\t<span"); WriteLiteral(" class=\"file-name\""); WriteLiteral(">base64</span>\r\n"); WriteLiteral("\t\t \t\t<span"); WriteLiteral(" class=\"file-size\""); WriteLiteral(">0Kb</span>\r\n"); } else { WriteLiteral("\t\t \t\t\t<span"); WriteLiteral(" class=\"file-name\""); WriteLiteral(">"); Write(sc.Name); WriteLiteral("</span>\r\n"); WriteLiteral("\t\t \t\t<span"); WriteLiteral(" class=\"file-size\""); WriteLiteral("> "); Write(sc.FileSize); WriteLiteral("Kb</span>\r\n"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t</li>\r\n"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t\t</ul>\r\n\t\t\t\t\t\t\t\t\t\t\t</div>\r\n"); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t\t"); if (test.HasChildren) { Write(Include("RecurseNodes", test)); } WriteLiteral("\t\t\t\t\t\t\t\t\t\t</div>\r\n </li>\r\n"); } WriteLiteral(" </ul> \r\n </div>\r\n " + " </div>\r\n <div"); WriteLiteral(" class=\"test-content scrollable\""); WriteLiteral("></div>\r\n </div>\r\n </div>\r\n </div>\r\n" + " </div>\r\n </div>\r\n"); WriteLiteral("\t"); Write(Include("Scripts")); WriteLiteral("\r\n</body>\r\n</html>"); } } } ------------- END ----------- List of loaded Assemblies: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.AssemblyResolver.dll Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.Adapter.dll Loaded Assembly: C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.ExecutionCommon\15.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.ExecutionCommon.dll Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Enterprise.AspNetHelper.dll Loaded Assembly: C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Common\15.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Common.dll Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.TeamSystem.Licensing.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll Loaded Assembly: C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Resource\15.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Resource.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.QualityTools.AgentObject.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll Loaded Assembly: C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.UnitTestFramework\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel.dll Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\ABB.Robotics.Apps.Shell.Automation.Tests.dll Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\SharpAvi.dll Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\ABB.Robotics.Apps.Shell.Automation.dll Loaded Assembly: C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.WindowsStore.CodedUITestFramework.dll Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\ABB.Automation.Common.dll Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\ExtentReports.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Diagnostics\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Diagnostics.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration.Install\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.Install.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.ConsoleHost\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.ConsoleHost.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Utility\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Utility.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Commands.Management\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Commands.Management.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Management.Infrastructure\v4.0_1.0.0.0__31bf3856ad364e35\Microsoft.Management.Infrastructure.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceProcess\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.ServiceProcess.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Management\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Management.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.PowerShell.Security\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.PowerShell.Security.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.WSMan.Management\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.WSMan.Management.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.WSMan.Runtime\v4.0_3.0.0.0__31bf3856ad364e35\Microsoft.WSMan.Runtime.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.DirectoryServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.DirectoryServices.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Windows.Appx.PackageManager.Commands\v4.0_10.0.0.0__31bf3856ad364e35\Microsoft.Windows.Appx.PackageManager.Commands.dll Loaded Assembly: C:\WINDOWS\system32\WinMetadata\Windows.Management.winmd Loaded Assembly: C:\WINDOWS\system32\WinMetadata\Windows.Foundation.winmd Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\MongoDB.Bson.dll Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\RazorEngine.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\appium-dotnet-driver.dll Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\WebDriver.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\FluentAssertions.dll Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\Notifications.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Accessibility\v4.0_4.0.0.0__b03f5f7f11d50a3a\Accessibility.dll Loaded Assembly: C:\AutomationResults\INANTHA3_IN-L-7209614 2019-08-24 20_19_30\Out\System.Web.Razor.dll Loaded Assembly: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll. at RazorEngine.Compilation.DirectCompilerServiceBase.CompileTypeImpl(TypeContext context) at RazorEngine.Compilation.DirectCompilerServiceBase.CompileType_Windows(TypeContext context) at RazorEngine.Compilation.DirectCompilerServiceBase.CompileType(TypeContext context) at RazorEngine.Templating.RazorEngineCore.CreateTemplateType(ITemplateSource razorTemplate, Type modelType) at RazorEngine.Templating.RazorEngineCore.Compile(ITemplateKey key, Type modelType) at RazorEngine.Templating.RazorEngineService.CompileAndCacheInternal(ITemplateKey key, Type modelType) at RazorEngine.Templating.RazorEngineService.GetCompiledTemplate(ITemplateKey key, Type modelType, Boolean compileOnCacheMiss) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.RunCompile(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at AventStack.ExtentReports.Reporter.ExtentHtmlReporter.Flush(ReportAggregates reportAggregates) at AventStack.ExtentReports.Core.ExtentObservable.<>c__DisplayClass59_0.<NotifyReporters>b__0(IExtentReporter x) at System.Collections.Generic.List`1.ForEach(Action`1 action) at AventStack.ExtentReports.Core.ExtentObservable.NotifyReporters() at AventStack.ExtentReports.Core.ExtentObservable.Flush() at AventStack.ExtentReports.ExtentReports.Flush() Can you please help. I am using the latest version.
namilkimfree commented 4 years ago

I same issue , execute extent.flush() not exception on window local machine but throw same exception on mac - jenkins

anshooarora commented 4 years ago

Can you share the step which causes this exception?

anshooarora commented 4 years ago

Please use the .Net Standard release, version 4.1.0-alpha. This should be resolved.

namilkimfree commented 4 years ago

Please use the .Net Standard release, version 4.1.0-alpha. This should be resolved.

Yes, Thank you :))

ScottyMac52 commented 4 years ago

Is there a better answer here? I am working an API contract at Microsoft and we are wanting to use Extent Reports to get HTML for our integration tests in spec Flow but currently we are using .NET Core 2.2 which is not in LTS. We have a story in the backlog to decide on .NET Core 2.1 or 3.1 since they are LTS but in the meantime the exception in the Flush() is a major blocker.

anshooarora commented 4 years ago

@ScottyMac52 What version are you using? 4.1.0-beta1? This issue was resolved in this version's alpha, I just haven't had a chance to complete the release version, but will be focusing on .NET as Java's v5 was released today.

shubautomation commented 2 years ago

Hi @anshooarora ,

I am using Extent reporting 4.1.0 version with Specflow + C# + Visual Studio. Everything is working as expected on windows. But when I ran the same configuration code on MAC, Extent reporting is throwing exceptational when Flush(); functions gets executed. It is happening only when there is assertion failure in the Tests. Report is getting generated as expected when Test case passed.

.Net 6.0(Windows), .Net core 3.1(Target framework .Net 6.0) on MAC Visual Studio 2022(Windows) Visual Studio 2019(Mac) Extent Reporting 4.1.0 both on windows and Mac

Issue is only with MAC Error/exceptational: RazorEngine.Templating.TemplateCompilationException " Error while creating the template".

Could you please help me to resolve the issue?

namilkimfree commented 2 years ago

@shubautomation

Can you provide a sample code where the issue occurs?

shubautomation commented 2 years ago

Hi @namilkimfree

I am not sure if you re looking for the below code: Kindly let me know if you need any other thing: .Net 6.0(Windows), .Net core 3.1(Target framework .Net 6.0) on MAC Visual Studio 2022(Windows) Visual Studio 2019(Mac) Extent Reporting 4.1.0 both on windows and Mac

Issue: Is happening only on Mac OS. Not sure problem is with MAC OS or Extent reporting plugin. Please help, it is blocker for me.

In Hooks.cs :

[AfterTestRun] public static void AfterTestRun() { _extentReports.Flush();

    }  

Feature: @Login Scenario: Login page with valid username and password

Given user is on xyz website When user login with "abc" username and "xyz*" password Then user should be on "Home" page And user logout from the application

Step File: [Given(@"user is on xyz website")] public void GivenUserIsOnXyzWebsite() { Launch();

    }

[When(@"user login with ""([^""])"" username and ""([^""])"" password")] public void WhenUserLoginWithUsernameAndPassword(string username, string password) { loginPage.Login(username, password); }

[Then(@"user should be on ""([^""]*)"" page")] public void ThenUserShouldBeOnPage(string page) {

        commonPage.ValidatePage(page);
    }

In Login page: public void ValidatePage(page){

 Assert.AreEqual("Home", page);

}

So when ever assertion failed, lets say "Home is not equal to Home" then execute _extentReports.Flush(); in AfterTestRUn function it throws below error

RazorEngine.Templating.TemplateCompilationException has been thrown

"Errors while compiling a Template.\nPlease try the following to solve the situation:\n If the problem is about missing/invalid references or multiple defines either try to load \n the missing references manually (in the compiling appdomain!) or\n Specify your references manually by providing your own IReferenceResolver implementation.\n See https://antaris.github.io/RazorEngine/ReferenceResolver.html for details.\n Currently all references have to be available as files!\n If you get 'class' does not contain a definition for 'member': \n try another modelType (for example 'null' to make the model dynamic).\n NOTE: You CANNOT use typeof(dynamic) to make the model dynamic!\n Or try to use static instead of anonymous/dynamic types.\nMore details about the error:\n - warning: (19, 5) The variable 'isbdd' is assigned but its value is never used\n\t - warning: (8, 4) Unnecessary using directive.\n\t - warning: (6, 4) Unnecessary using directive.\n\t - warning: (12, 4) Unnecessary using directive.\n\t - warning: (5, 4) Unnecessary using directive.\n\t - warning: (11, 4) Unnecessary using directive.\n\t - warning: (10, 4) Unnecessary using directive.\n\t - warning: (7, 4) Unnecessary using directive.\n\t - warning: (9, 4) Unnecessary using directive.\n\t - error: (0, 0) Unexpected error writing debug information -- 'Value cannot be null. (Parameter 'type')'\nTemporary files of the compilation can be found in (please delete the folder): /var/folders/25/7ht4yd49307crjldf5cmkbf80000gn/T/RazorEngine_pfpgylcf.1gz\nThe template we tried to compile is: \n------------- START -----------\n@using AventStack.ExtentReports\r\n@using AventStack.ExtentReports.ViewDefs\r\n@using RazorEngine\r\n@using RazorEngine.Templating\r\n@{\r\n\tvar isbdd = false;\r\n\tvar cls = \"\";\r\n\tif (Model.TestList.Count > 0 && Model.TestList[0].IsBehaviorDrivenType)\r\n\t{\r\n\t\tisbdd = true;\r\n\t\tcls = \"bdd-report\";\r\n\t}\r\n}\r\n<!DOCTYPE html>\r\n\r\n@Include(\"Head\")\r\n<script src=\"https://cdn.rawgit.com/extent-framework/extent-github-cdn/7cc78ce/spark/js/jsontree.js\">\r\n<

namilkimfree commented 2 years ago

@shubautomation

OS: MAC TargetFramework: NET 6.0 IDE: vs2019(mac)

and what is specflow version? and Are you usin to specflow.nunit? or specflow.runner?

can i have .csproj package list information ?

shubautomation commented 2 years ago

Hi @namilkimfree

just note that in VS 2019 we don't have option to select any other version apart from .Netcore 3.1. Hence I selected .Netcoreapp 3.1 but later I changed the Target framework from project properties option) to .Net 6.0. But issue of Flush(); is in both .Netcore3.1 and 6.0 (Only On Mac)

I am using specflow.nunit.

.csproj >>

Project Sdk="Microsoft.NET.Sdk">

TargetFramework >netcoreapp3.1

sPackable>false>IsPackable

PropertyGroup

<PackageReference Include="NUnit" Version="3.13.3"
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1"
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2"
<PackageReference Include="SpecFlow" Version="3.9.74"
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74"
<PackageReference Include="SpecFlow.NUnit" Version="3.9.74"
<PackageReference Include="Selenium.WebDriver" Version="4.5.1"
<PackageReference Include="ExtentReports" Version="4.1.0"
<PackageReference Include="Selenium.Support" Version="4.5.1"
<PackageReference Include="log4net" Version="2.0.15"
<PackageReference Include="SeleniumExtras.WaitHelpers" Version="1.0.2"
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57"
<PackageReference Include="ExtentReports.Core" Version="1.0.3"
namilkimfree commented 2 years ago

@shubautomation

It seems to have been fixed in version 5.

Currently, only beta version exists.

I am using it separately through fork.

There seem to be two ways.

  1. Use 5.0.0-alpha6.

  2. Use ExtentReports-custom-package.

try change package ExtentReporter version 5.0.0-alpha6

`

`

and I don't think is needed. `

`
shubautomation commented 2 years ago

Hi @namilkimfree

Thanks for the response.

so this 2 ways are only applicable for MAC os ? as for windows it is working as expected.

Also, I know Version= "5.0.0-alpha6" can be downloaded from here: (https://www.nuget.org/packages/ExtentReports/5.0.0-alpha)

But can u tell me how to use "Use ExtentReports-custom-package."

namilkimfree commented 2 years ago

Even if you use PackageReference Include="ExtentReports" Version="5.0.0-alpha6", it works normally on Windows, Linux, and mac.

CustomPackage: `

`

That package, and it's almost identical to the original functionality. If there are necessary functions or issues, they are added or used.

shubautomation commented 2 years ago

Hi @namilkimfree

Thanks for helping me. My some other questions. Sry to trouble again

In above comments Anshu mentioned to use .net standard with Extend Reporting 4.1.0, so I want to make sure I do not need to change anything from .Net related. Extent reporting 5.0-alpha version will resolve this issue? I am right here.?

image

namilkimfree commented 2 years ago

Hi @shubautomation

If the following packages are included in the 5.x version, they exist in branch: develop.

link: https://github.com/extent-framework/extentreports-csharp/blob/develop/ExtentReports/ExtentReports.csproj

If you check the above package

anshooarora

https://github.com/anshooarora/RazorEngine/tree/master/RazorEngine.NetCore/Compilation

Prevent debug errors on macOS

Fixed the issue.

Try changing the package version and test

shubautomation commented 2 years ago

Hi @shubautomation

If the following packages are included in the 5.x version, they exist in branch: develop.

link: https://github.com/extent-framework/extentreports-csharp/blob/develop/ExtentReports/ExtentReports.csproj

If you check the above package

anshooarora

https://github.com/anshooarora/RazorEngine/tree/master/RazorEngine.NetCore/Compilation

Prevent debug errors on macOS

Fixed the issue.

Try changing the package version and test

Hi @namilkimfree

Did not get you here completely due to my limited knowledge on .Net.

Also, When I upgrade to ExtentReports" Version="5.0.0-alpha6, public static ExtentReports _extentReports; gives error "ExtentReports" is namespace but used as Type". And I am not able to find class ExtentReports anymore in 5.0.0-alpha6 version. Do we have any other equivalent class for Extentreports or any reference document for 5.0.0-alpha6 version. ?

namilkimfree commented 2 years ago

Hi @shubautomation

It seems that NameSpace and Class name are the same.

using System.IO;
using AventStack.ExtentReports;
using TechTalk.SpecFlow;
using AventStack.ExtentReports.Reporter;

namespace MacLinuxTest
{
    public class Hooks
    {

        private static ExtentReports _extentReports;

        [BeforeTestRun]
        public static void BeforeTestRun()
        {
            _extentReports = new ExtentReports();

            var baseDirectory = Path.GetDirectoryName(typeof(Hooks).Assembly.Location);

            var fileName = "nonWindows.html";
            var path = Path.Combine(baseDirectory,fileName);

            var extent = new ExtentReports();
            var spark = new ExtentSparkReporter("Spark.html");
            extent.AttachReporter(spark);

            var sparkReport = new ExtentSparkReporter(path);
            sparkReport.Config = new
                AventStack.ExtentReports.Reporter.Config.ExtentSparkReporterConfig()
                {
                    Theme = AventStack.ExtentReports.Reporter.Config.Theme.Dark
                };

            _extentReports.AttachReporter(sparkReport);

        }

        [AfterTestRun]
        public static void AfterTestRun()
        {
            _extentReports.Flush();

        }  

    }
}
shubautomation commented 2 years ago

Hi @shubautomation

using System.IO;
using AventStack.ExtentReports;
using TechTalk.SpecFlow;
using AventStack.ExtentReports.Reporter;

namespace MacLinuxTest
{
    public class Hooks
    {

        private static ExtentReports _extentReports;

        [BeforeTestRun]
        public static void BeforeTestRun()
        {
            _extentReports = new ExtentReports();

            var baseDirectory = Path.GetDirectoryName(typeof(Hooks).Assembly.Location);

            var fileName = "nonWindows.html";
            var path = Path.Combine(baseDirectory,fileName);

            var extent = new ExtentReports();
            var spark = new ExtentSparkReporter("Spark.html");
            extent.AttachReporter(spark);

            var sparkReport = new ExtentSparkReporter(path);
            sparkReport.Config = new
                AventStack.ExtentReports.Reporter.Config.ExtentSparkReporterConfig()
                {
                    Theme = AventStack.ExtentReports.Reporter.Config.Theme.Dark
                };

            _extentReports.AttachReporter(sparkReport);

        }

        [AfterTestRun]
        public static void AfterTestRun()
        {
            _extentReports.Flush();

        }  

    }
}

Hi @namilkimfree

Not sure what is wrong after Upgrade to 5.10-alpha version but not able to find the class ExtentReports. Please find the below screenshot

namilkimfree commented 2 years ago

Hi @shubautomation

i use to verison
<PackageReference Include="ExtentReports" Version="5.0.0-alpha6" />

i'm not use 5.10-alpha

my .csproj image

shubautomation commented 2 years ago

Hi @shubautomation

i use to verison <PackageReference Include="ExtentReports" Version="5.0.0-alpha6" />

i'm not use 5.10-alpha

my .csproj image

Hi @namilkimfree

Sorry that was typo error. My .csproj

PackageReference Include="ExtentReports" Version="5.0.0-alpha6" /> PackageReference Include="NUnit" Version="3.13.3" /> PackageReference Include="NUnit3TestAdapter" Version="4.2.1" /> PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> PackageReference Include="SpecFlow" Version="3.9.74" /> PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74" /> PackageReference Include="SpecFlow.NUnit" Version="3.9.74" /> PackageReference Include="Selenium.WebDriver" Version="4.5.1" />

PackageReference Include="Selenium.Support" Version="4.5.1" />
PackageReference Include="log4net" Version="2.0.15" />
PackageReference Include="SeleniumExtras.WaitHelpers" Version="1.0.2" />
PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
PackageReference Include="ExtentReports.Core" Version="1.0.3" />

but I am not able to find ExtentReports class anymore

namilkimfree commented 2 years ago

Hi @shubautomation

you are also remove

It is caused by that package.

Delete that package.

shubautomation commented 2 years ago

Hi @shubautomation

you are also remove

It is caused by that package.

Delete that package.

Hi @namilkimfree

Are you taking abt package "PackageReference Include="ExtentReports.Core" Version="1.0.3"?? Sorry your comment was not clear.

namilkimfree commented 2 years ago

Hi @shubautomation Sorry. missing my comment.

Yes, remove "PackageReference Include="ExtentReports.Core" Version="1.0.3

shubautomation commented 2 years ago

Hi @namilkimfree

First of all thanks a lot for helping me my initial issue for Razor template got fixed when I upgraded to 5.10-alpha and also I removed the package PackageReference Include="ExtentReports.Core" Version="1.0.3 which resolve my ExtentReports issue as well.

Can you please help me 2 more issues:

  1. Earlier, I was capturing the screenshots for the failed Test cases and getting attached to the extent reporting by using below function. But once I removed the ExtentReports.Core package the class "MediaEntityModelProvider" is not available any more.

Can you suggest what is the method/function/class in Extent report 5.1.0-alpha6 use to take screenshots and attached to the extend reporting? Any document reference for 5.0.0-alpha6 version?

public static MediaEntityModelProvider CaptureScreenshot(string name) //{ // var screenshot = ((ITakesScreenshot)driver).GetScreenshot().AsBase64EncodedString; // return MediaEntityBuilder.CreateScreenCaptureFromBase64String(screenshot, name).Build(); //}

  1. If I am running multiple Test Cases, lets say 2, only the second ran Test Case listed in the report and not the first ran Test case

@namilkimfree @anshooarora Can you please help or else point to any reference link/document.

namilkimfree commented 2 years ago

@shubautomation

  1. Earlier, I was capturing the screenshots for the failed Test cases and getting attached to the extent reporting by using below function. But once I removed the ExtentReports.Core package the class "MediaEntityModelProvider" is not available any more.

-->

public static Media CaptureScreenshot(string name)
{
var screenshot = ((ITakesScreenshot)driver).GetScreenshot().AsBase64EncodedString;
 var media = MediaEntityBuilder.CreateScreenCaptureFromBase64String(base64, screenShotName).Build();
return media; 
}

docs: https://www.extentreports.com/docs/versions/5/net/index.html

  1. can i have a your sample code?
shubautomation commented 2 years ago

@shubautomation

  1. Earlier, I was capturing the screenshots for the failed Test cases and getting attached to the extent reporting by using below function. But once I removed the ExtentReports.Core package the class "MediaEntityModelProvider" is not available any more.

-->

public static Media CaptureScreenshot(string name)
{
var screenshot = ((ITakesScreenshot)driver).GetScreenshot().AsBase64EncodedString;
 var media = MediaEntityBuilder.CreateScreenCaptureFromBase64String(base64, screenShotName).Build();
return media; 
}

docs: https://www.extentreports.com/docs/versions/5/net/index.html

  1. can i have a your sample code?

@namilkimfree Sample code for hooks.cs from where I have listed all things related to Report

using TechTalk.SpecFlow; using AventStack.ExtentReports; using AventStack.ExtentReports.Reporter; using AventStack.ExtentReports.Gherkin.Model; using Demo_Test.Base; using TechTalk.SpecFlow.Infrastructure; using OpenQA.Selenium; //using NUnit.Engine.Extensibility; using NUnit.Framework.Interfaces; using System.Reflection; using OpenQA.Selenium.Remote; using System.IO; using System;

namespace Demo_Test.Support { [Binding]

public sealed class Hooks : BaseClass
{
    // For additional details on SpecFlow hooks see http://go.specflow.org/doc-hooks

    private static FileStream filestream;
    public static StreamWriter sWriter;

    [BeforeTestRun]
    public static void BeforeTestRun()
    {
        string test = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;
        // Console.WriteLine("Report " + test);

        var fileName = "nonWindows.html";

        string reportPath = Path.Combine(test, "Report", fileName);
        Console.WriteLine("Report full path : ", reportPath);
        //_extentHtmlReporter = new ExtentHtmlReporter(test + @"\Report\");

        //_extentHtmlReporter = new ExtentHtmlReporter(reportPath);

        _extentSparkReporter = new ExtentSparkReporter(reportPath);

        //old path not required  //_extentHtmlReporter = new ExtentV3HtmlReporter(test + @"\Report\");
        //_extentHtmlReporter.Config.ReportName = "System Test";

        _extentSparkReporter.Config.ReportName = "System Test";
        _extentReports = new ExtentReports();

        //_extentReports.AttachReporter(_extentHtmlReporter);

        _extentReports.AttachReporter(_extentSparkReporter);

        _extentReports.AddSystemInfo("Host Name", "MAC");
        _extentReports.AddSystemInfo("OS", "MAC");

    }

    [BeforeFeature]
    public static void BeforeFeatureStart(FeatureContext featureContext)
    {
        if (featureContext != null)
        {
            _feature = _extentReports.CreateTest<Feature>(featureContext.FeatureInfo.Title,
                featureContext.FeatureInfo.Description);
            _feature.Info("This is test report of Info");
            _feature.Log(Status.Info, "Starting the report");
        }

    }

    [BeforeScenario]
    public static void BeforeScenarioStart(ScenarioContext scenarioContext)
    {
        if (scenarioContext != null)
        {
            _scenarioContext = scenarioContext;
            _scenario = _feature.CreateNode<Scenario>(scenarioContext.ScenarioInfo.Title,
                 scenarioContext.ScenarioInfo.Description);

        }

        driver = GetDriverInstance();

    }

    [AfterStep]

    public void AfterEachStep()
    {
        ScenarioBlock scenarioBlock = _scenarioContext.CurrentScenarioBlock;

        switch (scenarioBlock)
        {
            case ScenarioBlock.Given:

                CreateNode<Given>();

                break;
            case ScenarioBlock.When:

                CreateNode<When>();
                break;
            case ScenarioBlock.Then:

                CreateNode<Then>();
                break;
            default:

                CreateNode<And>();
                break;
        }
    }

    public void CreateNode<T>() where T : IGherkinFormatterModel
    {
        if (_scenarioContext.TestError != null)
        {

            var mediaEntity = CaptureScreenshot(_scenarioContext.ScenarioInfo.Title.Trim());
            _scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.Message + "\n" +
                _scenarioContext.TestError.StackTrace);
        }
        else
        {
            _scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Pass("");

        }
    }

    [AfterTestRun]
    public static void AfterTestRun()
    {

        _extentReports.Flush();
        //BaseClass.driver.Close();

    }

    [BeforeScenario("Firefox", Order = 1)]
    public void FirstBeforeScenario()
    {
        // Example of ordering the execution of hooks
        // See https://docs.specflow.org/projects/specflow/en/latest/Bindings/Hooks.html?highlight=order#hook-execution-order

        //TODO: implement logic that has to run before executing each scenario

    }

    [AfterScenario]
    public void AfterScenario()
    {
        sWriter.WriteLine("Test Finished: " + DateTime.Now);
        if (_scenarioContext.TestError != null)
        {
            sWriter.WriteLine("Test Result: " + _scenarioContext.ScenarioInfo.Title + "_Fail");

        }
        else
        {
            sWriter.WriteLine("Test Result: " + _scenarioContext.ScenarioInfo.Title + "_Pass");

        }

        driver.Dispose();
        driver = null;
        sWriter.Close();
        filestream.Close();

    }

}

}

namilkimfree commented 2 years ago

Hi @shubautomation


using System;
using System.IO;
using AventStack.ExtentReports;
using AventStack.ExtentReports.Gherkin.Model;
using TechTalk.SpecFlow;
using AventStack.ExtentReports.Reporter;
using AventStack.ExtentReports.Reporter.Config;

namespace MacLinuxTest
{
    [Binding]
    public sealed class Hooks 
    {
        // For additional details on SpecFlow hooks see http://go.specflow.org/doc-hooks

        private static ExtentSparkReporter _extentSparkReporter;
        private static ExtentReports _extentReports;

        private static ExtentTest _feature;

        private static ScenarioContext _scenarioContext;

        private static ExtentTest _scenario;

        [BeforeTestRun]
        public static void BeforeTestRun()
        {
            string test = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;
            // Console.WriteLine("Report " + test);

            var fileName = "nonWindows.html";

            string reportPath = Path.Combine(test, "Report", fileName);
            Console.WriteLine("Report full path : ", reportPath);
            //_extentHtmlReporter = new ExtentHtmlReporter(test + @"\Report\");

            //_extentHtmlReporter = new ExtentHtmlReporter(reportPath);

            _extentSparkReporter = new ExtentSparkReporter(reportPath);

            //old path not required  //_extentHtmlReporter = new ExtentV3HtmlReporter(test + @"\Report\");
            //_extentHtmlReporter.Config.ReportName = "System Test";

            _extentSparkReporter.Config.ReportName = "System Test";
            _extentReports = new ExtentReports();

            //_extentReports.AttachReporter(_extentHtmlReporter);

            _extentReports.AttachReporter(_extentSparkReporter);

            _extentReports.AddSystemInfo("Host Name", "MAC");
            _extentReports.AddSystemInfo("OS", "MAC");

        }

        [BeforeFeature]
        public static void BeforeFeatureStart(FeatureContext featureContext)
        {
            if (featureContext != null)
            {
                _feature = _extentReports.CreateTest<Feature>(featureContext.FeatureInfo.Title,
                    featureContext.FeatureInfo.Description);
                _feature.Info("This is test report of Info");
                _feature.Log(Status.Info, "Starting the report");
            }

        }

        [BeforeScenario]
        public static void BeforeScenarioStart(ScenarioContext scenarioContext)
        {
            if (scenarioContext != null)
            {
                _scenarioContext = scenarioContext;
                _scenario = _feature.CreateNode<Scenario>(scenarioContext.ScenarioInfo.Title,
                     scenarioContext.ScenarioInfo.Description);

            }

            //driver = GetDriverInstance();

        }

        [AfterStep]

        public void AfterEachStep()
        {
            ScenarioBlock scenarioBlock = _scenarioContext.CurrentScenarioBlock;

            switch (scenarioBlock)
            {
                case ScenarioBlock.Given:

                    CreateNode<Given>();

                    break;
                case ScenarioBlock.When:

                    CreateNode<When>();
                    break;
                case ScenarioBlock.Then:

                    CreateNode<Then>();
                    break;
                default:

                    CreateNode<And>();
                    break;
            }
        }

        public void CreateNode<T>() where T : IGherkinFormatterModel
        {
            if (_scenarioContext.TestError != null)
            {

                //var mediaEntity = null;
                _scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.Message + "\n" +
                    _scenarioContext.TestError.StackTrace);
            }
            else
            {
                _scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Pass("");

            }
        }

        [AfterTestRun]
        public static void AfterTestRun()
        {

            _extentReports.Flush();
            //BaseClass.driver.Close();

        }

        [AfterScenario]
        public void AfterScenario()
        {

            if (_scenarioContext.TestError != null)
            {

            }
            else
            {

            }

            //driver.Dispose();
            //driver = null;

        }

    }
}

image

shubautomation commented 2 years ago

using System; using System.IO; using AventStack.ExtentReports; using AventStack.ExtentReports.Gherkin.Model; using TechTalk.SpecFlow; using AventStack.ExtentReports.Reporter; using AventStack.ExtentReports.Reporter.Config;

namespace MacLinuxTest { [Binding] public sealed class Hooks { // For additional details on SpecFlow hooks see http://go.specflow.org/doc-hooks

    private static ExtentSparkReporter _extentSparkReporter;
    private static ExtentReports _extentReports;

    private static ExtentTest _feature;

    private static ScenarioContext _scenarioContext;

    private static ExtentTest _scenario;

    [BeforeTestRun]
    public static void BeforeTestRun()
    {
        string test = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName;
        // Console.WriteLine("Report " + test);

        var fileName = "nonWindows.html";

        string reportPath = Path.Combine(test, "Report", fileName);
        Console.WriteLine("Report full path : ", reportPath);
        //_extentHtmlReporter = new ExtentHtmlReporter(test + @"\Report\");

        //_extentHtmlReporter = new ExtentHtmlReporter(reportPath);

        _extentSparkReporter = new ExtentSparkReporter(reportPath);

        //old path not required  //_extentHtmlReporter = new ExtentV3HtmlReporter(test + @"\Report\");
        //_extentHtmlReporter.Config.ReportName = "System Test";

        _extentSparkReporter.Config.ReportName = "System Test";
        _extentReports = new ExtentReports();

        //_extentReports.AttachReporter(_extentHtmlReporter);

        _extentReports.AttachReporter(_extentSparkReporter);

        _extentReports.AddSystemInfo("Host Name", "MAC");
        _extentReports.AddSystemInfo("OS", "MAC");

    }

    [BeforeFeature]
    public static void BeforeFeatureStart(FeatureContext featureContext)
    {
        if (featureContext != null)
        {
            _feature = _extentReports.CreateTest<Feature>(featureContext.FeatureInfo.Title,
                featureContext.FeatureInfo.Description);
            _feature.Info("This is test report of Info");
            _feature.Log(Status.Info, "Starting the report");
        }

    }

    [BeforeScenario]
    public static void BeforeScenarioStart(ScenarioContext scenarioContext)
    {
        if (scenarioContext != null)
        {
            _scenarioContext = scenarioContext;
            _scenario = _feature.CreateNode<Scenario>(scenarioContext.ScenarioInfo.Title,
                 scenarioContext.ScenarioInfo.Description);

        }

        //driver = GetDriverInstance();

    }

    [AfterStep]

    public void AfterEachStep()
    {
        ScenarioBlock scenarioBlock = _scenarioContext.CurrentScenarioBlock;

        switch (scenarioBlock)
        {
            case ScenarioBlock.Given:

                CreateNode<Given>();

                break;
            case ScenarioBlock.When:

                CreateNode<When>();
                break;
            case ScenarioBlock.Then:

                CreateNode<Then>();
                break;
            default:

                CreateNode<And>();
                break;
        }
    }

    public void CreateNode<T>() where T : IGherkinFormatterModel
    {
        if (_scenarioContext.TestError != null)
        {

            //var mediaEntity = null;
            _scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Fail(_scenarioContext.TestError.Message + "\n" +
                _scenarioContext.TestError.StackTrace);
        }
        else
        {
            _scenario.CreateNode<T>(_scenarioContext.StepContext.StepInfo.Text).Pass("");

        }
    }

    [AfterTestRun]
    public static void AfterTestRun()
    {

        _extentReports.Flush();
        //BaseClass.driver.Close();

    }

    [AfterScenario]
    public void AfterScenario()
    {

        if (_scenarioContext.TestError != null)
        {

        }
        else
        {

        }

        //driver.Dispose();
        //driver = null;

    }

}

}

Hi @namilkimfree

Thanks for sharing the report. I don't think there is any difference in your hooks.cs file and mine. But still I am not able to get all the ran Tcs. Only latest ran Tcs is getting reported in the report.

Can you suggest which file can cause prob will share the code for the same with you. There might be some config changes in 5 Version of extent report as it might be overriding my previous Tcs ran result. Please help on the same

After Analysis: I found that for every scenario it is executing [BeforeTestRun] block which should be ideally executed only once for 1 run and same for [AfterTestRun] which is getting executed for every scenario. These both blocks cover code to generate the report hence it is getting executed again for every scenario the previous results and getting overridden . In My windows OS, [AfterTestRun] and [BeforeTestRun] blocks are excuting only once per run not with every scenarios. Can you please help how to fix this and this wont look like reporting issue, moreover it is related to nUnit + Specflow issue. Please suggest.

namilkimfree commented 2 years ago

Hi @shubautomation [AfterTestRun] and [BeforeTestRun]

It is called only once. Even if there are 3 scenarios

are you using parallelExecution?

shubautomation commented 2 years ago

Hi @shubautomation [AfterTestRun] and [BeforeTestRun]

It is called only once. Even if there are 3 scenarios

are you using parallelExecution?

Hi @namilkimfree

I am not using Parallel Execution and when I am running the 2 scenarios it is executing in sequence and not in parallel. As I said in my previous comment that when I did analysis I found that [AfterTestRun] and [BeforeTestRun] is executing for every scenario run and not once for complete run. Hence my report is overriding the previous result.

Any pointers how to fix this?. It is very strange why it is happening like this. Anything to do with nUnit.assembly.hooks.cs?

namilkimfree commented 2 years ago

Hello @shubautomation

Can you upload your code to your github repository?

shubautomation commented 2 years ago

GitHubDemoProject.zip

Hi @namilkimfree

I have created the sample project and zip file is attached with this comment. Please use this project. Issue is reproducible as only latest ran TC is reported in the report because [BeforeTestRun] and [AfterTestRun] is getting executed with every scenarios. Also [OnetimeSetup] and [OneTimeTearDown] block in nUnit.AssemblyHooks.cs is also getting executed with every scenarios, ideally this also should be run only once per execution.

Let me know if you any issue while downloading or using my sample project.

Note: I am using Mac OS + Specflow + nUnit + VS 2019 + DotNet coreapp 3.1. Also I have installed specflow integration package with Mac OS. https://github.com/straighteight/SpecFlow-VS-Mac-Integration as Specflow is not officially released for MAC OS.

Are you also using MAC OS +Specflow+nUnit + VS 2019?

Do you mind sharing your email? We can continue our discussion over email. Do not want spam the other users.

shubautomation commented 2 years ago

Hi @namilkimfree

Did you get chance to look into the sample project? I am not able to find the solution yet.

namilkimfree commented 2 years ago

Hi @shubautomation

sorry

i don't have Mac OS

Reporting the results of two scenarios is success on Windows OS.

I have a Mac at work, but it's taking a long time to set up an old Mac mini.

wait please

shubautomation commented 2 years ago

Hi @shubautomation

sorry

i don't have Mac OS

Reporting the results of two scenarios is success on Windows OS.

I have a Mac at work, but it's taking a long time to set up an old Mac mini.

wait please

Hi @namilkimfree

Thanks a lot for the reply.

Yes. in Windows OS everything is working as expected for me as well. Sure will wait for your update.

shubautomation commented 1 year ago

Hi @namilkimfree,

Did u get the change to reproduce the issue in MAC?

namilkimfree commented 1 year ago

@shubautomation hi

When running with the project, a report with two scenarios passed without any problems is created.

My mac: vs2022, dotnet6

image