Could not load type 'Microsoft.Extensions.Hosting.GenericHostWebHostBuilderExtensions' from assembly 'Microsoft.AspNetCore.Hosting, Version=2.2.7.0
AnsweredHi guys,
I'm trying to create some specflow tests and using a Webhost to get autorization tokens. My idea is: before each test, Webhost gives me a HttpClient already authorized and I'am able to use it in further steps.
These are my packages:
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.5" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.5.286" />
<PackageReference Include="SpecRun.SpecFlow" Version="3.5.22" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
(I've included this recently, but it doesnt worked)
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
My Before test case:
HostFixture class with WebHost:
Exception:
This webhost works well on a simple unit test with Xunit, but it doesn't when using Specflow bindings. Any suggestions or ideas?
Thanks
-
Please use the latest SpecFlow+ Runner version. We fixed some assembly load issues with the latest releases, so there is a chance that the issue is then gone.
If not, try to switch to the `SharedAppDomain` test isolation mode. Details here: https://docs.specflow.org/projects/specflow-runner/en/latest/Profile/Environment.html#testthreadisolation
1 -
Problem solved. Thank you so much Andreas !!
0 -
Dimitri Menezes Was it the version update or the switch to `SharedAppDomain`?
0 -
I did both, but it solved switching to ShareAppDomain
0 -
👍
0
Please sign in to leave a comment.
Comments
5 comments