extent-framework / extentreports-csharp

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

Field not found on .Flush in NUnit Console #227

Open davidhenderickx opened 2 months ago

davidhenderickx commented 2 months ago

Hello,

I'm implementing extent with Selenium in C# .Net 8.0 I'm following this tutorial: https://www.youtube.com/watch?v=89YBs9mK9V8&list=PLaDALgeX9grofiW_34GGWY9JpTMfhSsfb&index=13 Instead of using the htmlreporter, I'm using sparkreporter since htmlreporter is depreciated

When running with > dotnet test, my tests run fine and the report gets created.

But, when I run with the NUnit console > nunit3-console.exe TA_Framework.dll, the .flush returns me the following error and no report is generated:

Field not found: 'AventStack.ExtentReports.Model.Context.Manager.NamedAttributeContextManager`1.Context'.
   at CompiledRazorTemplates.Dynamic.RazorEngine_de4fe5cd9fa1409f85e2a4d8a01fcda0.ExecuteAsync()
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
   at CompiledRazorTemplates.Dynamic.RazorEngine_de4fe5cd9fa1409f85e2a4d8a01fcda0.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   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.RunCompile(IRazorEngineService service, String name, 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.ExtentSparkReporter.OnNext(ReportEntity value)
   at System.Reactive.Subjects.Subject`1.OnNext(T value)
   at AventStack.ExtentReports.Core.ReactiveSubject.Flush()
   at AventStack.ExtentReports.Core.AbstractProcessor.OnFlush()
   at AventStack.ExtentReports.ExtentReports.Flush()
   at Utils.Reports.Extent.ExtentReporter.EndReporting() in C:\Users\JX8198\Development\TA_Framework\Reporting\Extent\ExtentReporter.cs:line 92
   at TA_Framework.Tests.BaseTest.TestTeardown() in C:\Users\JX8198\Development\TA_Framework\Tests\BaseTest.cs:line 61

I tried it in version 5.0.0, 5.0.2 and 5.0.4, all of them have the same issue.

My .csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>disable</Nullable>
    <IsPackable>false</IsPackable>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
    <PackageReference Include="NUnit" Version="3.13.3" />
    <PackageReference Include="NUnit.Console" Version="3.18.1" />
    <PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
    <PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
    <PackageReference Include="coverlet.collector" Version="6.0.0" />
    <PackageReference Include="Selenium.Support" Version="4.23.0" />
    <PackageReference Include="Selenium.WebDriver" Version="4.23.0" />
    <PackageReference Include="ExtentReports" Version="5.0.0" />
    <PackageReference Include="NLog" Version="5.3.2" />
  </ItemGroup>
</Project>
joshuafontany commented 2 weeks ago

I have also run into this error. ExtentReports flushes ok when run from VS UI, or with dotnet test. Not with nunit3-console.exe, same error.

kv-naveen commented 1 day ago

@anshooarora can you please prioritize this issue. we cant update to nunit 4 \ .net8.0 because of this.