Mar*_*cin 2 unit-testing asp.net-core visual-studio-2017
尝试在Visual Studio 2017中运行测试时,所有都在编译时没有问题,但是当我尝试创建服务器和客户端进行测试时:
this.Server = new TestServer(
new WebHostBuilder()
.UseStartup<Startup>()
.UseContentRoot(di.FullName));
this.Client = this.Server.CreateClient();
Run Code Online (Sandbox Code Playgroud)
该TestServer是抱怨错误的依赖(它会尝试加载版本1.0.0),即使TestHost包是:
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="1.1.1" />
Run Code Online (Sandbox Code Playgroud)
测试失败也有异常:
Cannot find method: 'System.Net.Http.HttpClient Microsoft.AspNetCore.TestHost.TestServer.CreateClient()'..
Run Code Online (Sandbox Code Playgroud)
Mar*_*cin 12
它与VS 2017中的错误测试模板手动添加在顶部有关 <PropertyGroup>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Run Code Online (Sandbox Code Playgroud)
在csproj文件修复问题
| 归档时间: |
|
| 查看次数: |
1447 次 |
| 最近记录: |