在 Visual Studio 2017 中未发现单元测试 [英] Unit Tests not discovered in Visual Studio 2017

查看:25
本文介绍了在 Visual Studio 2017 中未发现单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从安装 VS 2017 以来,我一直在苦苦挣扎.现在看来单元测试只能从命令行dotnet test"运行.

I have been struggling with VS 2017 since I installed it. Now it seems Unit Tests will only run from the command line "dotnet test."

我的项目是 .NET Core 1.1.1.我已经安装了 1.1.1 的 SDK 和框架更新.

My project is .NET Core 1.1.1. I have the SDK and the framework update for 1.1.1 installed.

我在 MSDN (https://msdn.microsoft.com/en-us/library/ms182532.aspx) 也以完全相同的方式失败.

I have tried the sample at MSDN (https://msdn.microsoft.com/en-us/library/ms182532.aspx) which also fails exactly the same way.

用于测试和主项目的所有 NuGet 包都是最新的.并且测试项目和主项目都没有错误地构建.测试从命令行成功运行.

All NuGet packages for the tests and the main project are current. And both the test project and the main project build without errors. An the tests run successfully from the command line.

有没有人让单元测试在 VS 2017 中运行,如果有的话如何?

Has anyone gotten Unit Tests to run in VS 2017, if so how?

谢谢,约翰

这是一个在 GitHub.这是 xUnit 的一个示例,但我尝试过在 MS 测试中构建的 NUnit 和 Visual Studio.无论我进行什么测试或进行什么更改,我都无法让 VS 测试运行程序找到任何测试.

Here is an example of a simple test project that is not working on GitHub. This is an example with xUnit but I have tried NUnit and visual studio built in MS tests. No matter what testing or what changes I make I cannot get the VS test runner to find any tests.

  • 删除 VS 测试缓存文件 DEL %TEMP%\VisualStudioTestExplorerExtensions
  • 重启VS
  • 关闭/打开测试浏览器
  • 对于已安装的 xUnit Microsoft.DotNet.InternalAbstractions(见SO帖子)
  • 对于 NUnit,请确保安装了适配器并且与 NUnit 软件包的版本 (3) 相同
  • test ->测试设置 ->默认处理器架构设置为x86
  • Deleting VS test cache files DEL %TEMP%\VisualStudioTestExplorerExtensions
  • Restarting VS
  • Closing/Opening test explorer
  • for xUnit installed Microsoft.DotNet.InternalAbstractions (see SO post)
  • for NUnit ensure adapter installed and same version (3) as NUnit package
  • test -> test settings -> default processor architecture is set to x86

问题
任何人都可以在 VS2017(.csproj 项目文件)中提供 .Net Core 1.1.0 解决方案的工作示例,其中 VS 测试资源管理器成功找到单元测试 OR 向我展示给定示例中的问题.

The Question
Can anyone please provide a working example of a .Net Core 1.1.0 solution in VS2017 (.csproj project files) where the VS test explorer successfully finds the unit tests OR show me the issue in the example given.

推荐答案

这对我有用(不知道是不是更改工作区损坏了某些东西的结果):

This just worked for me (don't know if it is the result of changing workspaces that corrupted something):

删除 %TEMP%\VisualStudioTestExplorerExtensions 中的 VS 测试缓存文件并重新启动 VS2017.

Deleting VS test cache files in %TEMP%\VisualStudioTestExplorerExtensions and restart VS2017.

这篇关于在 Visual Studio 2017 中未发现单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆