JamesRandall / FunctionMonkey

Write more elegant Azure Functions with less boilerplate, more consistency, and support for REST APIs. Docs can be found at https://functionmonkey.azurefromthetrenches.com
MIT License
294 stars 49 forks source link

Integration test error post upgrade to 4.0.56-beta.4 #135

Open davidjsteele opened 4 years ago

davidjsteele commented 4 years ago

Hi,

Having trouble running my integration tests after upgrading to latest version of FM and Azure SDK running on .net Core 3.1.

    <PackageReference Include="FluentAssertions" Version="5.10.2" />
    <PackageReference Include="FunctionMonkey.Testing" Version="4.0.56-beta.4" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
    <PackageReference Include="NSubstitute" Version="4.2.1" />
    <PackageReference Include="Xbehave" Version="2.4.1" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1"> 
    <PackageReference Include="FunctionMonkey.Testing" Version="4.0.56-beta.4" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />

App runs fine, just the tests that are broken.

System.ArgumentNullException : Value cannot be null. (Parameter 'provider')
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Mvc.ObjectResult.ExecuteResultAsync(ActionContext context)
   at I2BAPI.Application.Framework.Handlers.ApiResponse.ExecuteResultAsync(ActionContext context)

Any insight would be much appreciated. Thanks

mmeckes commented 4 years ago

I'm getting the same issue with integration tests on 4.0.56-beta.4.

mmeckes commented 4 years ago

@davidjsteele did you ever find a solution for this? I'm still struggling to get integration tests to run with ExecuteHttpAsync

davidjsteele commented 4 years ago

@mmeckes if memory serves this was actually down to a problem with discovery of app.config files as part of ioc resolution. If you can provide more info might be able to help

mmeckes commented 4 years ago

@davidjsteele any help appreciated. I know it's been a while since you raised this issue. My tests were working fine but something happened when I upgraded to 4.0.56-beta.4. I also updated a bunch of other packages so it could be something else, so I'm spending some time trying to track it down.

<PackageReference Include="FunctionMonkey.Testing" Version="4.0.56-beta.4" />
    <PackageReference Include="JetBrains.DotMemoryUnit" Version="3.1.20200127.214830" />
    <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
    <PackageReference Include="NSubstitute" Version="4.2.1" />
    <PackageReference Include="Xbehave" Version="2.4.1" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">

As soon as I call ExecuteHttpAsync I the error below where the provider is not getting injected in correctly. It does feel like there is some config that is off that is stopping it from resolving the dependencies correctly, but I'm struggling to track it down.

System.ArgumentNullException : Value cannot be null. (Parameter 'provider')
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Mvc.StatusCodeResult.ExecuteResult(ActionContext context)
   at Microsoft.AspNetCore.Mvc.ActionResult.ExecuteResultAsync(ActionContext context)
   at FunctionMonkey.Testing.Implementation.AspNetRuntime.CreateHttpResponse(ActionContext actionContext, IActionResult actionResult)
   at FunctionMonkey.Testing.AcceptanceTestScaffold.ExecuteHttpAsync[TResult](ICommand`1 command, HttpMethod method)
   at MakeItDonate.Tests.Acceptance.AddCharityShould.<>c__DisplayClass2_0.<<ReceiveBadRequestOnInvalidCharity>b__1>d.MoveNext() in C:\Users\mattm\source\repos\MakeItDonate\MakeItDonate.Tests\Acceptance\AddCharityShould.cs:line 67
--- End of stack trace from previous location where exception was thrown ---
   at Xbehave.Execution.Invoker.<>c__DisplayClass0_1.<<Invoke>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---