Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field not found on .Flush in NUnit Console #227

Open
davidhenderickx opened this issue Aug 14, 2024 · 4 comments
Open

Field not found on .Flush in NUnit Console #227

davidhenderickx opened this issue Aug 14, 2024 · 4 comments

Comments

@davidhenderickx
Copy link

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
Copy link

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
Copy link

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

@Yuliagrin
Copy link

Yuliagrin commented Nov 5, 2024

I have the same issue. updated from .net6 to .Net 8 . Nunit Console runner 3.18. ExtentReport version 5.0.4
Error:
TearDown : System.MissingFieldException : Field not found: 'AventStack.ExtentReports.Model.Context.Manager.NamedAttributeContextManager1.Context'. --TearDown at CompiledRazorTemplates.Dynamic.RazorEngine_4bab4e82015f4cea855aba26e118c869.ExecuteAsync() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) at CompiledRazorTemplates.Dynamic.RazorEngine_4bab4e82015f4cea855aba26e118c869.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(Action1 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.Subject1.OnNext(T value) at AventStack.ExtentReports.Core.ReactiveSubject.Flush() at AventStack.ExtentReports.Core.AbstractProcessor.OnFlush() at AventStack.ExtentReports.ExtentReports.Flush() at TechnoModule.BaseContext.TearDown() in C:\sourceCodeGit\CyberquantQA\AutomationE2E\TechnoModule\baseContext\BaseContext.cs:line 331 at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter1.GetResult()
at NUnit.Framework.Internal.AsyncToSyncAdapter.Await[TResult](Func1 invoke) at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func1 invoke)
at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunTearDown(TestExecutionContext context)

@michaelchambers324
Copy link

I am seeing the same issue. Runs fine via VS UI but not with the nunit console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants