我正在使用扩展报告来生成报告,但是在Extent.flush()方法上测试执行失败。我正在使用
此代码以前可以使用,但现在无法正常工作。返回错误:
System.IO.FileNotFoundException HResult = 0x80070002 消息=无法加载文件或程序集'System.Web.Razor,版本= 3.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'。该系统找不到指定的文件。 来源= RazorEngine 堆栈跟踪: 在RazorEngine.Compilation.CSharp.CSharpDirectCompilerService..ctor处(布尔型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) 在AventStack.ExtentReports.Reporter.ExtentHtmlReporter.Flush() 在AventStack.ExtentReports.Model.Report。<> c.b__29_1(IExtentReporter x) 在System.Collections.Generic.List1.ForEach(Action
1操作中) 在AventStack.ExtentReports.Model.Report.NotifyReporters() 在AventStack.ExtentReports.Model.Report.Flush() 在AventStack.ExtentReports.ExtentReports.Flush() 在C:\ Users \ kotar \ source \ repos \ XUnitTestProject5 \ XUnitTestProject5 \ UnitTest1.cs:第25行的XUnitTestProject5.UnitTest1.Test1()处
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();
答案 0 :(得分:2)
如果使用的是.net core,则必须使用“ ExtentReports.Core” NuGet软件包而不是“ ExtentReports”,并按如下所示初始化扩展对象:
public AventStack.ExtentReports.ExtentReports _extent = new
AventStack.ExtentReports.ExtentReports();