如何进行vscode扩展的覆盖率导出 [英] How to do Coverage exports for vscode extensions

查看:283
本文介绍了如何进行vscode扩展的覆盖率导出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过很多教程,如何进行vscode扩展.喜欢:

I have seen a lot of tutorials how to make vscode extensions. Like:

https://code.visualstudio.com/docs/extensions/testing-extensions

有很多教程如何进行coverage导出,有很多方法,但是我没有看到很好的示例,这些示例可以遵循他们文档中的示例并使用vscode扩展(它们需要extensionHost而不是nodejs).

And there is many tutorials how to do coverage exports, there many ways how to do it, but I didn't seen good examples which would follow the examples from their docs and work with vscode extensions (they need the extensionHost instead of nodejs).

我有所有用摩卡编写的测试,这些测试按照他们的文档所建议的捆绑在vscode中.

I have all the tests written in the mocha which is bundled in the vscode as proposed by their documents.

我尝试进行实验,但遇到了麻烦,是否有任何提示或指示可以继续并使我的过程重新开始工作?

I tried to experiment and I'm stuck, are there any hints or directions where I could continue and get my process working again?

推荐答案

有效的答案在我的原始问题的注释中.但是为了简化和归纳必须要做的事情,以及我个人做了哪些步骤.并非所有步骤都是必不可少的,也是必需的,但是这些步骤非常方便:

The answer which worked is in the comments to my original question. But to simplify and boil down what had to be done, and what steps I did personally. Not all steps are really essential and required, but these steps made it pretty convient:

  • 将tanbul,istanbul-coveralls,gulp,gulp-json-editor,工作服作为DEV依赖项安装到我的软件包中
  • 在测试中包括了MS随附的伊斯坦布尔测试运行程序,用于进行vscode扩展测试
  • 修改了测试以直接运行伊斯坦布尔赛跑者而不是摩卡赛跑者(测试本身可以保持原样).
  • 现在附加了对伊斯坦布尔奔跑者的引用,我必须阅读coverconfig.json才能知道如何进行覆盖范围本身(要忽略的部分,在何处使用源,在何处输出结果,结果应采用何种格式等.).
  • 增加了对gitignore和vscode项目的覆盖,因为它们不会在UI中惹恼我,也不会污染回购协议.
  • 添加了一些Visual Studio启动器/任务,以使我更容易从UI触发它们
  • 安装了vscode插件以显示排水沟的覆盖范围: https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters ,然后将"lcov.path":["coverage/lcov.info"](或任何位置)添加到我的项目设置中您将获得覆盖率),以便该插件可以直接在用户界面中读取并显示覆盖率.
  • 设置gulp以删除旧的覆盖率结果,并在每次运行时开始新的结果
  • 添加了用于常规测试和coverage变体的npm脚本
  • 更改了travis步骤,因此coverage变体现在正在运行,而不是常规的非coverage变体.添加了脚本步骤,因此可以运行Coveralls模块,并将结果从coverage/lcov.info广播到 https://coveralls.io/网站.(我认为需要登录并进行首次设置才能在其网站上运行)
  • installed istanbul, istanbul-coveralls, gulp, gulp-json-editor, coveralls to my package as the DEV dependencies
  • included the MS supplied istanbul test runner for vscode extension testing into my tests
  • modified the tests to run an istanbul runner instead of mocha runner directly (the tests itself could stay as they are).
  • attached reference to the istanbul runner now I had to read the coverconfig.json to know how to do the coverage itself (what parts to ignore, where is source, where to output results, what formats the results should be etc...).
  • added coverage to gitignore and to vscode project as so they will not annoy me in the UI and will not polute the repo.
  • added few visual studio launchers/tasks to make it easier for me to trigger them from the UI
  • installed vscode plugin to display the coverage in the gutters: https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters and then added to my project settings the "lcov.path": [ "coverage/lcov.info" ] (or whatever location you will have the line coverage) so the plugin can read and show the coverage directly in the UI.
  • setup gulp to delete old coverage results and start new ones on each run
  • added npm scripts for regular tests and for the coverage variant
  • changed travis steps so the coverage variant is running now instead of the generic non-coverage one. Added script step so the coveralls module is run and broadcasts the results from the coverage/lcov.info to the https://coveralls.io/ website. (i think signing in and doing the first-time setup is required to make it work on their website)

现在,每次提交travis都会自行完成工作,我可以在自述文件中使用工作服横幅来快速了解我的报道范围.而且,您可以使用gulp监视它的更改并在本地进行构建/测试,并在UI中快速反馈您的测试覆盖了哪些行.

Now on each commit travis will do the work by itself and I can use coveralls banner inside my readme to give quick glipse how well is my coverage. And you can use gulp to watch it for changes and build/test locally and have fast feedback in the UI what lines were covered by your tests.

设置类似于列出的链接:

The setup is similar to the listed links:

https://github.com/Microsoft/vscode-mssql

https://github.com/kenhowardpdx/vscode-gist/pull/10

这篇关于如何进行vscode扩展的覆盖率导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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