Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
447 views
in Technique[技术] by (71.8m points)

testing - How can the code coverage data from Flutter tests be displayed?

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:libdataCustomer.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
....

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?

question from:https://stackoverflow.com/questions/50789578/how-can-the-code-coverage-data-from-flutter-tests-be-displayed

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can also install lcov and convert the lcov.info file to HTML pages and then see the result in the browser with sorting option

Installing in Ubuntu:

sudo apt-get update -qq -y
sudo apt-get install lcov -y

Installing in Mac:

brew install lcov

Run tests, generate coverage files and convert to HTML

flutter test --coverage
genhtml coverage/lcov.info -o coverage/html

Note: This way you can add it to circleci artifacts and coveralls as well


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...