升级到 MsTest V2 不再看到我的测试项目

Upgrade to MsTest V2 no longer sees my test projects

我有几个单元测试项目,在我的项目中使用旧的内置 Microsoft.VisualStudio.QualityTools.UnitTestFramework 引用。最近我决定删除它并安装 MsTest V2 nuget 包。一切都编译,但现在 none 我的测试被识别。没有进行其他代码更改。我可以在我的项目中看到参考文献:

<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" />

<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
    </Reference>

知道为什么会 happen/break 吗?

看起来你还有旧的测试适配器,你应该有:

<Import Project="..\packages\MSTest.TestAdapter.**2.0.0**\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.0.0\build\net45\MSTest.TestAdapter.targets')" />

你有 1.2。确保将 MSTest.TestFramework 和 MSTest.TestAdapter nuget 包添加到测试项目