allure-csharp icon indicating copy to clipboard operation
allure-csharp copied to clipboard

`dotnet test` command with xunit.runner.visualstudio fails with error

Open mingazhev opened this issue 1 year ago • 5 comments

I'm submitting a ...

  • [x] bug report
  • [ ] feature request
  • [ ] support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

I've updated an Allure reference in my project to 2.10.0 and here is the project reference list:

<ItemGroup>
    <PackageReference Include="Allure.XUnit" Version="2.10.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

When I run dotnet test inside a project folder there is an error:

[xUnit.net 00:00:00.09] Unable to patch XunitTestRunner's Void .ctor(Xunit.Abstractions.ITest, Xunit.Sdk.IMessageBus, System.Type, System.Object[], System.Reflection.MethodInfo, System.Object[], System.String, System.Collections.Generic.IReadOnlyList`1[Xunit.Sdk.BeforeAfterTestAttribute], Xunit.Sdk.ExceptionAggregator, System.Threading.CancellationTokenSource): System.NotImplementedException: The method or operation is not implemented.
   at HarmonyLib.PatchFunctions.UpdateWrapper(MethodBase original, PatchInfo patchInfo)
   at HarmonyLib.PatchProcessor.Patch()
   at HarmonyLib.Harmony.Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler, HarmonyMethod finalizer)
   at Allure.XUnit.AllureXunitPatcher.PatchXunitTestRunnerCtors(Harmony patcher)
[xUnit.net 00:00:00.09] No constructors of XunitTestRunner were pathched. Some theories may miss their parameters in the report

However, allure-results folder is populated with test results

Steps to reproduce

  1. Create a test project with references:
<ItemGroup>
    <PackageReference Include="Allure.XUnit" Version="2.10.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>
  1. Add sample test:
using System;
using Xunit;

namespace Hdp.FileStore.Application.Tests.Cases;

public class SampleTest
{
    [Fact]
    public void Test_some_code()
    {
        throw new Exception("Test");
    }
}
  1. Navigate to project folder and run dotnet test command

What is the expected behavior?

No error is shown, process exits with 0 code

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Allure version: 2.1.0
  • Test framework: xUnit

mingazhev avatar Nov 01 '23 15:11 mingazhev

Hi, @mingazhev ! Thank you for your report. Please, tell me the following:

  1. The target framework
  2. The OS
  3. The processor architecture

delatrie avatar Nov 01 '23 15:11 delatrie

Hi @delatrie, .NET 7.0 macOS 14.0 ARM64

mingazhev avatar Nov 01 '23 16:11 mingazhev

Hi @delatrie!

I have the same (?) issue with .NET 8.0, linux, x64: Allure.XUni 2.10.0 xunit 2.6.2 xunit.runner.visualstudio 2.5.4 Microsoft.NET.Test.Sdk 17.8.0

Unable to patch XunitTestRunner's Void .ctor(Xunit.Abstractions.ITest, Xunit.Sdk.IMessageBus, System.Type, System.Object[], System.Reflection.MethodInfo, System.Object[], System.String, System.Collections.Generic.IReadOnlyList`1[Xunit.Sdk.BeforeAfterTestAttribute], Xunit.Sdk.ExceptionAggregator, System.Threading.CancellationTokenSource): System.TypeInitializationException: The type initializer for 'MonoMod.Utils.DMDEmitDynamicMethodGenerator' threw an exception.
 ---> System.InvalidOperationException: Cannot find returnType fieeld on DynamicMethod
   at MonoMod.Utils.DMDEmitDynamicMethodGenerator..cctor()
   --- End of inner exception stack trace ---
   at MonoMod.Utils.DMDEmitDynamicMethodGenerator.GenerateCore(DynamicMethodDefinition dmd, Object context)
   at MonoMod.Utils.DMDGenerator`1.Generate(DynamicMethodDefinition dmd, Object context)
   at MonoMod.Utils.DynamicMethodDefinition.Generate(Object context)
   at MonoMod.Utils.DynamicMethodDefinition.Generate()
   at HarmonyLib.MethodPatcher.CreateReplacement(Dictionary`2& finalInstructions)
   at HarmonyLib.PatchFunctions.UpdateWrapper(MethodBase original, PatchInfo patchInfo)
   at HarmonyLib.PatchProcessor.Patch()
   at HarmonyLib.Harmony.Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler, HarmonyMethod finalizer)
   at Allure.XUnit.AllureXunitPatcher.PatchXunitTestRunnerCtors(Harmony patcher)

AlexBar avatar Nov 20 '23 17:11 AlexBar

I think I got same issue with NUnit, .NET 7, MacOS Sonoma 14.1.1 (which is the latest version up to now) with Mac M1. ** The issue does not happen on MacOS Ventura 13.5 and 13.4 (I've tried with those 2 machine using same project and those are working fine**

Here is the error message:

OneTimeSetUp: System.NotImplementedException : The method or operation is not implemented. at HarmonyLib.PatchFunctions.UpdateWrapper(MethodBase original, PatchInfo patchInfo) at HarmonyLib.PatchProcessor.Patch() at HarmonyLib.Harmony.Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler, HarmonyMethod finalizer) at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.PatchRunnerFactory(Harmony patcher, MethodInfo factoryCandidate) at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.PatchRunnerFactories(Harmony patcher, IEnumerable1 factoryCandidates) at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.InjectTestPlanCheckToTestRunner(Harmony patcher) at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.InjectTestPlanSupport(IUnitTestRuntimeProvider unitTestRuntimeProvider) at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.EnsureTestPlanSupportInjected(IUnitTestRuntimeProvider unitTestRuntimeProvider) at Allure.SpecFlowPlugin.AllureBindingInvoker..ctor(SpecFlowConfiguration specFlowConfiguration, IErrorProvider errorProvider, ISynchronousBindingDelegateInvoker synchronousBindingDelegateInvoker, ITestRunnerManager testRunnerManager, IUnitTestRuntimeProvider unitTestRuntimeProvider) at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.ConstructorInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)`

tuanle1296 avatar Nov 22 '23 10:11 tuanle1296

I think I got same issue with NUnit, .NET 7, MacOS Sonoma 14.1.1 (which is the latest version up to now) with Mac M1. ** The issue does not happen on MacOS Ventura 13.5 and 13.4 (I've tried with those 2 machine using same project and those are working fine**

Here is the error message:

OneTimeSetUp: System.NotImplementedException : The method or operation is not implemented. at HarmonyLib.PatchFunctions.UpdateWrapper(MethodBase original, PatchInfo patchInfo) at HarmonyLib.PatchProcessor.Patch() at HarmonyLib.Harmony.Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler, HarmonyMethod finalizer) at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.PatchRunnerFactory(Harmony patcher, MethodInfo factoryCandidate) at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.PatchRunnerFactories(Harmony patcher, IEnumerable1 factoryCandidates) at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.InjectTestPlanCheckToTestRunner(Harmony patcher) at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.InjectTestPlanSupport(IUnitTestRuntimeProvider unitTestRuntimeProvider) at Allure.SpecFlowPlugin.SelectiveRun.AllureSpecFlowPatcher.EnsureTestPlanSupportInjected(IUnitTestRuntimeProvider unitTestRuntimeProvider) at Allure.SpecFlowPlugin.AllureBindingInvoker..ctor(SpecFlowConfiguration specFlowConfiguration, IErrorProvider errorProvider, ISynchronousBindingDelegateInvoker synchronousBindingDelegateInvoker, ITestRunnerManager testRunnerManager, IUnitTestRuntimeProvider unitTestRuntimeProvider) at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) at System.Reflection.ConstructorInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)`

I have a repro too

Peyzzz avatar Nov 30 '23 12:11 Peyzzz