如何显示Flutter测试中的代码覆盖率数据? [英] How can the code coverage data from Flutter tests be displayed?

查看:551
本文介绍了如何显示Flutter测试中的代码覆盖率数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Studio作为IDE来开发Flutter应用程序。

我试图编写测试并检查代码覆盖率,但无法解决如何查看其中的数据的问题。 IDE或任何其他应用程序。

通过运行 flutter测试--coverage

,似乎会生成覆盖报告。文件 /coverage/Icov.info

该文件看起来像这样:

I'm working on a Flutter app using Android Studio as my IDE.
I'm attempting to write tests and check the code coverage but I can't work out how to view the data in the IDE or any other application.
By running flutter test --coverage
A coverage report seems to be generated into a file /coverage/Icov.info
That file looks something like this:

SF:lib\data\Customer.g.dart
DA:9,2
DA:10,2
DA:11,2
DA:12,2
DA:13,2
DA:20,0
DA:21,0
DA:22,0
DA:23,0
DA:24,0
....

该文件似乎包含我的项目文件列表以及逐行覆盖数据。是否可以在Android Studio中查看此信息?

Looking at the file it seems to have a list of my project files with line by line coverage data. Is there a way to view this information in Android Studio?

推荐答案

您可以使用 Atom编辑器。

您只需要安装Dart和icov-info软件包。

You can view the code coverage generated by flutter with the Atom editor.
You just need to install the Dart and icov-info packages.

然后加载项目文件夹并按 Ctrl + Alt + c ,将显示覆盖范围为整个项目的覆盖范围以及突出显示的特定行。

Then you load your project folder and press Ctrl+Alt+c, coverage will be displayed with a summary of the whole projects coverage and also with specific line highlighting.

到目前为止,似乎没有任何适用于Android Studio的插件。

There doesn't appear to be any plugin for Android studio which does this as of yet.

这篇关于如何显示Flutter测试中的代码覆盖率数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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