为什么Visual Studio 2015/2017/2019 Test Runner无法发现我的xUnit v2测试

编程入门 行业动态 更新时间:2024-10-24 07:29:49
本文介绍了为什么Visual Studio 2015/2017/2019 Test Runner无法发现我的xUnit v2测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

更新:添加了2019;发现/运行者集成机制与2017& amp; 2015年,所以可能出错的关键因素是相同的。

UPDATE: Adding a 2019; the discovery/runner integration mechanism is same as per 2017 & 2015, so the key things that can go wrong are the same.

我读过为什么xUnit运行程序找不到我的测试,这涵盖了xUnit永远不会出现的原因能够找到您的测试,但是我的问题有所不同-我确信测试没有任何微妙的事情; (他们在其他环境中工作过,这似乎只是我的机器)-Visual Studio 2015 [Community Edition]中的Visual Studio测试运行器根本没有显示我的测试的任何。我没有做任何令人兴奋的事情;测试针对的是台式机上的xUnit v2。

I've read Why is the xUnit runner not finding my tests, which covers reasons xUnit would never be able to find your tests but my problem is different - I'm confident there's nothing subtle going on with my tests; (they have worked in other environments, this seems to be just my machine) - the Visual Studio Test Runner in Visual Studio 2015 [Community Edition] is simply not showing any of my tests. I'm not doing anything remotely exciting; the tests target xUnit v2 on the Desktop.

我在输出窗口中查看,在 Test 下根本看不到任何内容>在显示标签中的输出。

I've looked in the Output window and am not seeing anything in at all under Test in the Show output from tabs.

推荐答案

  • 从您的查询中消除发现例外;转到输出窗口(Ctrl-Alt-O),然后将显示输出从下拉菜单(Shift-Alt-S)切换为 Tests ,并确保没有发现例外

  • Eliminate discovery exceptions from your inquiries; go to the output Window (Ctrl-Alt-O), then switch the show output from dropdown (Shift-Alt-S) to Tests and make sure there are no discovery exceptions

    测试|测试设置|默认处理器体系结构如果您的测试特定于x86 / x64并且发现触发了误码,则可以提供帮助-相关异常,即不是 AnyCpu

    Test|Test settings|Default processor architecture can help if your tests are x86/x64 specific and discovery is triggering bittedness-related exceptions, i.e. not AnyCpu

    如该答案中所建议的(如果该技术有用,请对其进行投票) 运行桌面控制台运行程序(说明)可以很好地进行交叉检查,以消除其他可能性,例如损坏的配置文件:-

    As suggested in this answer(upvote it if the technique helps) running the desktop console runner (instructions) can be a good cross check to eliminate other possibilities, e.g. mangled config files:-

    packages\xunit.runner.console.2.2.0\tools\ xunit.console< tests.dll>

    注意不推荐使用xunit.runner.console 包-当您在VS中工作时,您可以进行 dotnet测试在CI中运行它们上下文也是如此

    NOTE The xunit.runner.console package is deprecated - when you get stuff working in VS, you'll be able to have dotnet test run them in CI contexts too

    阅读文档-它是全面,最新的,包括故障排除信息并执行PR:-

    Go read the documentation - it's comprehensive, up to date, includes troubleshooting info and takes PRs:-

    重要说明:如果您以前安装过xUnit Visual Studio Runner VSIX(扩展),则必须首先将其卸载。现在仅通过NuGet分发Visual Studio运行程序。要删除它,请转到工具> 扩展和更新。滚动到列表的底部,如果已安装xUnit,则将其卸载。这将迫使您重新启动Visual Studio。

    Important note: If you've previously installed the xUnit Visual Studio Runner VSIX (Extension), you must uninstall it first. The Visual Studio runner is only distributed via NuGet now. To remove it, to go Tools > Extensions and Updates. Scroll to the bottom of the list, and if xUnit is installed, uninstall it. This will force you to restart Visual Studio.

    如果发现或运行测试时遇到问题,则可能是Visual Studio内部运行程序缓存损坏的受害者。若要清除此缓存,请关闭Visual Studio的所有实例,然后删除文件夹%TEMP%\VisualStudioTestExplorerExtensions 。还要确保您的项目仅链接到Visual Studio运行程序NuGet包的单个版本( xunit.runner.visualstudio )。

    If you're having problems discovering or running tests, you may be a victim of a corrupted runner cache inside Visual Studio. To clear this cache, shut down all instances of Visual Studio, then delete the folder %TEMP%\VisualStudioTestExplorerExtensions. Also make sure your project is only linked against a single version of the Visual Studio runner NuGet package (xunit.runner.visualstudio).

    以下步骤对我有用:

  • (仅如果您怀疑机器上有严重的混乱情况-通常,更常见的情况是尚未安装Visual Studio集成)

    DEL%TEMP%\VisualStudioTestExplorerExtensions 如建议:-

    PS> del $ env:TEMP\VisualStudioTestExplorerExtensions

    安装NuGet软件包 xunit.runner.visualstudio 在所有测试项目中

    Install the NuGet Package xunit.runner.visualstudio in all test projects

    • Paket:

    • Paket:

    .paket\paket add nuget xunit.runner.visualstudio -i

    您需要在 paket.dependencies 中添加以下内容:

    You need to end up with the following in your paket.dependencies:

    nuget xunit.runner.visualstudio version_in_path:true

    注意 version_in_path:true 位很重要

    Note the version_in_path: true bit is important

    Nuget:转到程序包管理器控制台(Alt-T,N,O )和

    Nuget: Go to Package Manager Console (Alt-T,N,O) and

    Install-Package xunit.runner.visualstudio)

  • 重建以确保 xunit.runner 最终出现在输出目录

    Rebuild to make sure xunit.runner ends up in the output dir

    关闭测试浏览器 <-这是我所缺少的

    Close Test Explorer <- this was the missing bit for me

    重新打开测试浏览rer(Alt-S,W,T)

    Re-open Test Explorer (Alt-S,W,T)

    运行所有测试(Ctrl R,A)

    更多推荐

    为什么Visual Studio 2015/2017/2019 Test Runner无法发现我的xUnit v2测试

    本文发布于:2023-11-16 10:00:57,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1603273.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:发现   测试   Studio   Visual   xUnit

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!