.net core全局异常_.NET Core Code Coverage作为带有掩护的全局工具

.net core全局异常

.net core全局异常

Last week I blogged about "dotnet outdated," an essential .NET Core "global tool" that helps you find out what NuGet package reference you need to update.

上周,我在博客上发表了有关“ dotnet已过时”的博客,它是.NET Core必不可少的“全局工具”,可帮助您了解需要更新的NuGet软件包参考。

.NET Core Global Tools are really taking off right now. They are meant for devs - this isn't a replacement for chocolatey or apt-get - this is more like npm's global developer tools. They're putting together a better way to find and identify global tools, but for now Nate McMaster has a list of some great .NET Core Global Tools on his GitHub. Feel free to add to that list!

.NET Core全局工具现在正在真正腾飞。 它们仅供开发人员使用-不能替代Chocolatey或apt- get-更像是npm的全球开发人员工具。 他们正在寻找和识别全局工具的更好方法,但是现在Nate McMaster在他的GitHub上列出了一些很棒的.NET Core全局工具。 随意添加到该列表!

.NET tools can be installed like this:

.NET工具可以这样安装:

dotnet tool install -g <package id>

So for example:

因此,例如:

C:\Users\scott> dotnet tool install -g dotnetsay
You can invoke the tool using the following command: dotnetsay
Tool 'dotnetsay' (version '2.1.4') was successfully installed.
C:\Users\scott> dotnetsay

Welcome to using a .NET Core global tool!

You know, all the important tools. Seriously, some are super fun. ;)

您知道所有重要的工具。 认真地说,有些超级好玩。 ;)

Coverlet is a cross platform code coverage tool that's in active development. In fact, I automated my build with code coverage for my podcast site back in March. I combined VS Code, Coverlet, xUnit, plus these Visual Studio Code extensions

Coverlet是正在开发中的跨平台代码覆盖工具。 实际上,我在三月份就通过播客站点的代码覆盖实现了我的构建自动化。 我结合了VS Code, CoverletxUnit和这些Visual Studio Code扩展

for a pretty nice experience! All free and open source.

一个很好的体验! 所有免费和开源的。

I had to write a little PowerShell script because the "dotnet test" command for testing my podcast site with coverlet got somewhat unruly. Coverlet.msbuild was added as a package reference for my project.

我必须编写一些PowerShell脚本,因为使用Coverlet测试我的播客站点的“ dotnet test”命令有些不合规。 Coverlet.msbuild已添加为我的项目的软件包参考。

dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov .\hanselminutes.core.tests

I heard last week that coverlet had initial support for being a .NET Core Global Tool, which I think would be convenient since I could use it anywhere on any project without added references.

上周我听说Coverlet最初支持成为.NET Core全局工具,我认为这很方便,因为我可以在任何项目中的任何地方使用它而无需添加引用。

dotnet tool install --global coverlet.console

At this point I can type "Coverlet" and it's available anywhere.

此时,我可以输入“ Coverlet”,它可以在任何地方使用。

I'm told this is an initial build as a ".NET Global Tool" so there's always room for constructive feedback.

有人告诉我这是作为“ .NET全局工具”的初始版本,因此始终有建设性反馈的余地。

From what I can tell, I run it like this:

据我所知,我是这样运行的:

coverlet .\bin\Debug\netcoreapp2.1\hanselminutes.core.tests.dll --target "dotnet" --targetargs "test --no-build"

Note I have to pass in the already-built test assembly since coverlet instruments that binary and I need to say "--no-build" since we don't want to accidentally rebuild the assemblies and lose the instrumentation.

请注意,我必须通过已经构建的测试程序集,因为Coverlet仪器是二进制的,我需要说“ --no-build”,因为我们不想意外地重建程序集并丢失仪器。

Coverlet can generate lots of coverage formats like opencover or lcov, and by default gives a nice ASCII table:

Coverlet可以生成许多覆盖格式,例如opencover或lcov,并且默认情况下会提供一个漂亮的ASCII表:

88.1% Line Coverage in Hanselminutes.core

I think my initial feedback (I'm not sure if this is possible) is smarter defaults. I'd like to "fall into the Pit of Success." That means, even I mess up and don't read the docs, I still end up successful.

我认为我的初始反馈(不确定是否可行)是更明智的默认值 我想“落入成功之坑”。 这意味着,即使我搞砸了并且不阅读文档,我仍然可以成功。

For example, if I type "coverlet test" while the current directory is a test project, it'd be nice if that implied all this as these are reasonable defaults.

例如,如果我在当前目录是测试项目时键入“ coverlet test”,则最好隐含所有这些内容,因为这是合理的默认值。

.\bin\Debug\whatever\whatever.dll --target "dotnet" --targetargs "test --nobuild"

It's great that there is this much control, but I think assuming "dotnet test" is a fair assumption, so ideally I could go into any folder with a test project and type "coverlet test" and get that nice ASCII table. Later I'd be more sophisticated and read the excellent docs as there's lots of great options like setting coverage thresholds and the like.

拥有这么多控件非常好,但是我认为假设“ dotnet test”是一个合理的假设,因此理想情况下,我可以进入带有测试项目的任何文件夹,然后键入“ coverlet test”,并获得漂亮的ASCII表。 后来,我会变得更复杂,并阅读优秀的文档,因为有很多很棒的选择,例如设置覆盖率阈值等。

I think the future is bright with .NET Global Tools. This is just one example! What's your favorite?

我认为.NET全局工具的未来一片光明。 这只是一个例子! 你最喜欢什么?

Sponsor: Preview the latest JetBrains Rider with its built-in spell checking, initial Blazor support, partial C# 7.3 support, enhanced debugger, C# Interactive, and a redesigned Solution Explorer.

赞助商:预览最新的JetBrains Rider,包括其内置的拼写检查,Blazor初始支持,部分C#7.3支持,增强的调试器,C#Interactive和重新设计的解决方案资源管理器。

翻译自: https://www.hanselman.com/blog/net-core-code-coverage-as-a-global-tool-with-coverlet

.net core全局异常

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值