Reputation: 21
I am using extentent reports to generate report but the test excution fails on extent.flush() method. I am using
This code use to work previously but not working anymore. Error returned :
System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. Source=RazorEngine StackTrace: at RazorEngine.Compilation.CSharp.CSharpDirectCompilerService..ctor(Boolean strictMode, Func
1 markupParserFactory) at RazorEngine.Compilation.DefaultCompilerServiceFactory.CreateCompilerService(Language language) 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.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action
1 withWriter) at AventStack.ExtentReports.Reporter.ExtentHtmlReporter.Flush() at AventStack.ExtentReports.Model.Report.<>c.b__29_1(IExtentReporter x) at System.Collections.Generic.List1.ForEach(Action
1 action) at AventStack.ExtentReports.Model.Report.NotifyReporters() at AventStack.ExtentReports.Model.Report.Flush() at AventStack.ExtentReports.ExtentReports.Flush() at XUnitTestProject5.UnitTest1.Test1() in C:\Users\kotar\source\repos\XUnitTestProject5\XUnitTestProject5\UnitTest1.cs:line 25
var HTMLReporter = new ExtentHtmlReporter(@"C:\test\TestReport.html");
HTMLReporter.Configuration().Theme = AventStack.ExtentReports.Reporter.Configuration.Theme.Dark;
var extent = new ExtentReports();
extent.AttachReporter(HTMLReporter);
var featurename = extent.CreateTest<Feature>("login feature");
var scenario= featurename.CreateNode<Scenario>("Login as a user ");
scenario.CreateNode<Given>("user has access to the methos ");
extent.Flush();
Upvotes: 2
Views: 1526
Reputation: 1
I had a similar issue. Found that my RazorEngine.NetCore package was old. Updating the package helped generating the reports.
Check your RazorEngine.NetCore package under the Extent Reports package. It should be higher than version 3.x.x
Upvotes: 0
Reputation: 549
If you are using .net core, you have to use "ExtentReports.Core" NuGet package instead of "ExtentReports" and initialize your extent object like this :
public AventStack.ExtentReports.ExtentReports _extent = new
AventStack.ExtentReports.ExtentReports();
Upvotes: 3