如何在 Visual Studio 中创建和安装测试适配器 [英] How to create and install test adapter in Visual Studio

查看:32
本文介绍了如何在 Visual Studio 中创建和安装测试适配器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想'为 Visual Studio 创建一个量角器测试适配器.我发现我可以通过实现 ITestExecutor 和 ITestDiscoverer 来创建它.
我遵循 Marcel De Vries 文档(https://xpirit.com/wp-content/uploads/2016/03/Xpirit-magazine-2-Protractor-UI-testing.pdf) 但我找不到如何在 Visual 中添加我的扩展工作室.

I want' to create a protractor test adapter for Visual Studio. I have found I can create it with implementing ITestExecutor and ITestDiscoverer.
I follow the Marcel De Vries documentation (https://xpirit.com/wp-content/uploads/2016/03/Xpirit-magazine-2-Protractor-UI-testing.pdf) but I can't found how to add my extension in Visual Studio.

  • 我尝试将我的程序集直接添加到 \Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions 文件夹中.
  • 我尝试创建 Vsix 并安装它.(以 UnitTestExtension 作为资产)
  • 我尝试下载 Marcel 的项目 (https://github.com/XpiritBV/ProtractorAdapter)编译并安装它.
  • I have tried to add my assembly directly in the \Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions folder.
  • I have tried to create a Vsix and install it. (with UnitTestExtension as Asset)
  • I have tried to download Marcel's project (https://github.com/XpiritBV/ProtractorAdapter) compile and install it.

它不起作用,命令vstest.console.exe/listdiscoverers/UseVsixExtensions:true"没有列出我的发现者.并且 VS 找不到 JS 测试.

It's not work, the command "vstest.console.exe /listdiscoverers /UseVsixExtensions:true" doesn't list my discoverer. And JS tests don't found by VS.

我做错了什么?

推荐答案

为 VS 创建测试适配器的文档很差.有很多 URL 可以帮助理解如何使用 JS 自动化测试实现 UTE:

The documentation is very poor for creating test adapter for VS. There are many URL that can help to understand how implement UTE with JS automated test :

总结:
第 1 步:

In summary :
Step 1 :

  • 我们需要实现 ITestExecutor 来启动带有量角器的测试提示命令并返回结果.
  • 我们需要实现 ITestDiscoverer 来解析参数中的文件以查找其中的所有测试.

您可以在没有 VSix 的情况下测试此主要版本:转到 Visual Studio 测试扩展文件夹(C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions for VS 2013)和添加您的 DLL 和依赖项.尝试使用 Windows 命令提示符中的命令启动测试:

You can test this primary version without VSix : Go to Visual studio Test extension folder (C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions for VS 2013) and add your DLL and dependencies. Try to launch tests with commands like that in windows command prompt :

cd C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow  
vstest.console.exe "c:\test\test.js"

第 2 步:
默认情况下,Visual Studio 仅解析 .dll 和 .exe 文件.如果您想解析另一种文件类型(.lua、.js、...),您需要创建一个解析器来明确浏览源文件并查找所有测试.
您需要创建实现两个接口:

Step 2 :
By default Visual Studio only parse .dll and .exe files. If you want to parse another file type (.lua, .js, ...) you need to create a parser who explicitly browse source files and find all tests.
You need to create implement two Interfaces :

  • ITestContainerDiscoverer
  • ITestContainer

这个项目 (https://github.com/XpiritBV/ProtractorAdapter) 有助于理解如何实现以及如何调整代码以订阅项目中的任何更改(添加文件、编辑文件、项目加载等).

This project (https://github.com/XpiritBV/ProtractorAdapter) will be useful to understand how implement that and how adapt your code to subscribe on any changes in your project (Add file, Edit file, Project Load, etc.).

重要提示:您需要创建一个 VSix 项目来测试它!如果没有,Visual Studio 不会加载您的 TestContaineDiscoverer.

Important : You need to create a VSix project to test that ! If not, Visual Studio don't load your TestContaineDiscoverer.

重要 2 : 创建 VSix 文件时,需要解释两个 Assets :

Important 2 : When you create a VSix file, you need to explain two Assets :

  • 类型:Microsoft.VisualStudio.MefComponent/路径:|你的项目|
  • 类型:UnitTestExtension/路径|您的项目|

希望对某人有所帮助.

这篇关于如何在 Visual Studio 中创建和安装测试适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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