Sco*_*ham 6 c# unit-testing visual-studio
我有一个针对 net48 的 C# MsTest 项目。我已将其测试的项目更改为更新样式的 Microsoft.NET.Sdk csproj 格式,一切顺利。现在我也想转换单元测试项目。
我收到有关无法找到命名空间 Microsoft.VisualStudio.TestTools.UnitTesting 的错误:error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft'
为了解决这个问题,我添加了对 csproj 的程序集引用:
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
但我收到错误消息,无法找到它。
warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
当使用旧的 csproj 格式时,发现这是可以的。
我怎样才能找到这个程序集引用,或者完成这项工作的首选方法是什么?
以下是 3 种可能的解决方案:
MSTest.Framework
和MSTest.TestAdapter
.MSTestV2
仅支持 .NET Framework 4.5 及更高版本。Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
,并将其添加到您的 csproj 中,继续使用 MSTestV1:
<PropertyGroup><AssemblySearchPaths></AssemblySearchPaths></PropertyGroup>
Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
Program Files\Microsoft Visual Studio\2019\Professional\Common7\IDE\PublicAssemblies
我使用 #2 是因为我们的目标是 net40 并且有多个开发人员在不同版本的 VS 上工作。
归档时间: |
|
查看次数: |
1406 次 |
最近记录: |