基于Visual Studio和Nuget的测试运行器/适配器 [英] Visual Studio and Nuget based Test Runners/Adapters

查看:202
本文介绍了基于Visual Studio和Nuget的测试运行器/适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我开始了解基于nuget的适配器/运行器( http://xunit.github.io/docs/running-tests-in-vs.html )

Recently I came to know about the nuget based adapter/runner (http://xunit.github.io/docs/running-tests-in-vs.html)

我试图了解Visual Studio如何识别这些运行程序/适配器,然后再由TestWindow使用它们.

I was trying to understand how these runners/adapters are recognized by Visual Studio and then used by the TestWindow.

例如,如果我安装"xunit.runner.visualstudio" nuget程序包,则会发现我项目中所有基于xUnit的测试并在测试"窗口中显示.

For example, if I install "xunit.runner.visualstudio" nuget package all the xUnit based tests in my project are discovered and displayed in the Test Window.

我正在尝试了解VS如何使用安装在程序包文件夹中的程序包钩住测试发现"?

I am trying to understand how does VS hook the Test Discovery using the package installed in packages folder?

基于VS和nuget的适配器在哪里/如何被钩住?

Where/how do VS and nuget based adapter get hooked?

我尝试查找此信息,但我的Google Fu使我失败了. :(

I tried finding this information but my google fu failed me. :(

我检查了问题的答案(已安装自定义测试适配器通过NuGet并没有发现测试),它确实说VS将程序包复制到了路径%TEMP%\ VisualStudioTestExplorerExtensions,但这已经足够了.

I checked answer for the question (Custom test adapter installed via NuGet isn't discovering tests) and it does say that VS copies the packages to the path %TEMP%\VisualStudioTestExplorerExtensions but that's pretty much it.

推荐答案

由于这涉及VS内部的许多工作方式,因此我认为您不会得到完全确定的答案.但是,为了解决与您链接的问题,我查看了一堆反汇编的代码,因此我有一个很好的主意.看起来是这样的:

Since this involves a lot of how VS works internally, I don't think you'll get a totally definitive answer. However, to solve the issue you linked to I looked at a bunch of disassembled code, so I have a pretty good idea. Here's how it seems to work:

  1. 您构建一个引用名为Sample.TestAdapter的程序包的项目
  2. VS将Sample.TestAdapter目录从软件包复制到%TEMP%\ VisualStudioTestExplorerExtensions
  3. 某些事情会触发测试发现-重建总是如此,有时增量构建也是如此. vstest.console.exe在此处可用于调试.
  4. VS启动vstest.discovery.exe,该文件在VisualStudioTestExplorerExtensions中查找实现ITestDiscoverer的程序集
  5. 如果找到了ITestDiscoverer,则VS会使用可能包含测试的程序集列表对其进行调用
  6. 发现的测试由您的测试适配器发送回VS

据我所知,这是一个非常简单的基于反射的插件体系结构.希望有帮助.

So, as far as I can tell it's a pretty simple reflection based plug-in architecture. Hope that helps.

这篇关于基于Visual Studio和Nuget的测试运行器/适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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