[英]Tests not showing up in test explorer after adding .NET standard library to .NET framework project
No tests are showing up in the test explorer after I added a .NET standard library to a .NET framework 4.6.1 web api 2 project. 将.NET标准库添加到.NET Framework 4.6.1 Web api 2项目后,测试浏览器中没有测试显示。 (I am using MSTest) (我正在使用MSTest)
If I remove the .NET standard library and all the app & web config changes it made when I added it, the tests show up again. 如果我删除了.NET标准库,并且在添加时对其进行了所有应用和网络配置更改,则测试会再次显示。
My solution consists of: 我的解决方案包括:
What I did: 我做了什么:
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
I didn't enable PackageReference as mentioned in the github issue but my WebAPI project works fine. 我没有启用github问题中提到的PackageReference,但是我的WebAPI项目运行正常。 Its just that my unit tests have dissappeared from the test explorer. 只是我的单元测试从测试浏览器中消失了。
I tried the solution from this question , but that hasn't helped. 我从这个问题尝试了解决方案,但这没有帮助。
You also need to add the .NET Standard library to the test project itself. 您还需要将.NET Standard库添加到测试项目本身。
Since classic projects like the Web API project don't support transitive references, you also need to add the new project to the test project. 由于经典项目(例如Web API项目)不支持可传递引用,因此您还需要将新项目添加到测试项目中。 Then the build logic of the test project will see the .NET Standard reference and add the compatibility libraries and perform the binding redirect generation (due to the properties you added). 然后,测试项目的生成逻辑将看到.NET Standard参考,并添加兼容性库并执行绑定重定向生成(由于添加的属性)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.