小编JJe*_*ins的帖子

MSTest v2 无法在 net5.0-windows 上运行

我正在尝试创建一个 MSTest 项目来对 WinUI 3 开发进行单元测试。当针对 .NET 5.0 时,我能够通过测试资源管理器运行测试。

Project Reunion 需要 net5.0-windows10.0.19041 作为目标框架。当我尝试运行针对 net5.0-windows10.0.19041 的测试时,项目会构建,但测试不会运行。下面的测试日志的输出表明未找到 WinUI3-UnitTests.dll 文件,但指定位置中确实存在 WinUI3-UnitTests.dll。

[2021-10-05 9:38:57.350 AM] [MSTest][Discovery][WinUI3-Demo\WinUI3-UnitTests\bin\Debug\net5.0-windows10.0.19041\WinUI3-UnitTests.dll] Failed to discover tests from assembly WinUI3-Demo\WinUI3-UnitTests\bin\Debug\net5.0-windows10.0.19041\WinUI3-UnitTests.dll. Reason:File does not exist: WinUI3-Demo\WinUI3-UnitTests\bin\Debug\net5.0-windows10.0.19041\WinUI3-UnitTests.dll
Run Code Online (Sandbox Code Playgroud)

在 MSTest 输出日志中,它抛出 System.InvalidOperation 异常

TpTrace Information: 0 : 4580, 4, 2021/10/01, 16:05:24.725, 12341249999384, testhost.x86.dll, AssemblyResolver.OnResolve: Resolved assembly: Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices, from path: \WinUI3-Demo\WinUI3-UnitTests\bin\Debug\net5.0-windows10.0.19041\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
TpTrace Information: 0 : 4580, 4, 2021/10/01, 16:05:24.725, 12341250002103, testhost.x86.dll, MSTestExecutor.RunTests: Running tests from sources.
TpTrace Information: 0 : 4580, 4, 2021/10/01, 16:05:24.728, …
Run Code Online (Sandbox Code Playgroud)

c# mstest visual-studio .net-5 winui-3

5
推荐指数
1
解决办法
606
查看次数

标签 统计

.net-5 ×1

c# ×1

mstest ×1

visual-studio ×1

winui-3 ×1