A CLI tool to verify the test coverage of a pull request only, ignoring the rest of the project

Overview

flutter-ci

This is a CI tool that analyzes the coverage rate of a pull request, ignoring the lines that were not changed in the PR.

Motivation

The coverage rate threshold on CI tools is a common approach to encourage developers to write tests and keep improving the whole project's quality. Unfortunately, judging a pull request coverage by analyzing the coverage of the entire project is not always fair, especially on big refactor tasks, witch may naturally decrease the coverage rate.

This package tries a different approach to analyse the test coverage. We only analyse lines that have been added in the pull request. The coverage rate will be calculated by dividing the number of uncovered new lines by the number of new lines.

You can set thresholds to make tests fail on a CI. This package can also print those lines that were not covered, making it easier to identify the missing tests.

Installing

Add this line to your package's pubspec.yaml under the dev_dependencies section:

dev_dependencies:
  pull_request_coverage:

You should specify the version to avoid breaking changes

Usage

This package uses two information to generate its report:

  • A lcov.info file, generated by the flutter test --coverage command
  • A diff between the current branch and the main one, generated by the git diff command

Generating the lcov.info file

There is a known issue with the flutter test --coverage command. It may not report untested files. There is a workaround for it, described in this issue

Run the following command to generate the coverage/lcov.info file:

flutter test --coverage

Running pull_request_coverage

To check the PR's code, pull_request_coverage needs a diff between its branch and the target one. The diff is read from the STDIN input.

You can feed the STDIN using bash's | operator, like this:

git diff repository/main | flutter pub run pull_request_coverage

Output example:

Screenshot 2022-12-08 at 09 53 09

Uncovered lines are printed in red, starting with symbol.

Example with thresholds set and not showing uncovered lines:

git diff repository/main | flutter pub run pull_request_coverage --minimum-coverage 95 --maximum-uncovered-lines 5 --hide-uncovered-lines

Exit code

Code Description
0 Tests passed.
1 Tests failed (only when thresholds are set).
255 Execution has failed and tests were not executed.

Parameters

--lcov-file

  • default : coverage/lcov.info

The path to the lcov.info file generated by the flutter test --coverage command.

--exclude-suffix

  • default: .g.dart,.pb.dart,.pbenum.dart,.pbserver.dart,.pbjson.dart

Exclude all file paths that start with those suffixes, separated by commas

--exclude-prefix

Exclude all paths that start with those prefixes, separated by commas

--minimum-coverage

Fail the test if the coverage rate is below this value

--maximum-uncovered-lines

Fail the test if the the number of uncovered lines is less than this value

--report-fully-covered-files

  • default: true

The file path of each fully covered file will be printed, as a celebrating message =)

--show-uncovered-code

  • default: true

The source code of the uncovered lines will be printed, with a red font color, to make it easier to identify the missing tests. If this parameter is set to false, only the file path will be shown on the log.

--use-colorful-font

  • default : true

pull_request_coverage uses a colorful font to highlight uncovered lines. You can disable this by setting this parameter to false

You might also like...

A CLI tool and Dart package that can scrape file and directory URLs from h5ai instances.

h5ai scraper A CLI tool and Dart package that can scrape file and directory URLs from h5ai instances. Usage This tool requires the Dart SDK. It can be

Jan 4, 2023

A tool to help cli package authors make raising issues like bug reports more interactive for their users.

issue A tool to help cli package authors make raising issues like bug reports more interactive for their users. Features Interactive file based prompt

Oct 18, 2022

The one and only Docker Tool you will ever need again

# container_tool A new Flutter project. ## Getting Started This project is a starting point for a Flutter application. A few resources to get you

Nov 17, 2021

Flutter bloc cubit test knowdge - Flutter bloc cubit test knowdge

Flutter Bloc Simple Api This project is using weather api for featch data and di

Jan 3, 2022

Integration test - Copy of the official Flutter integration test plugin

integration_test This package enables self-driving testing of Flutter code on de

Jan 5, 2022

Integration Test Preview allows tests on multiple screen sizes in a single e2e test run.

Integration Test Preview allows tests on multiple screen sizes in a single e2e test run.

Integration Test Preview has pre-configured methods that allow for faster test deployment for end to end (e2e) test coverage (using Android and iOS pl

Aug 23, 2022

This is tool to create 3D Models which can be used in Flutter Applications. Tool is developed completely using Flutter.

three_d_model_tool A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you start

Nov 8, 2022

Flutter plugin for building pull to refresh effects with PullToRefreshNotification and PullToRefreshContainer quickly.

pull_to_refresh_notification Language: English | 中文简体 widget to build pull to refresh effects. Web demo for PullToRefreshNotification Chinese blog pul

Dec 28, 2022
Releases(1.0.1)
Owner
Tales Barreto
Tales Barreto
Verify code input. You can create a verify code input.

flutter_verification_code_input A Flutter package that help you create a verification input. Installing flutter_verification_code_input: git:

Tiny Express 49 Dec 7, 2022
Verify code input. You can create a verify code input.

flutter_verification_code_input A Flutter package that help you create a verification input. Installing flutter_verification_code_input: git:

Tiny Express 49 Dec 7, 2022
A package script for allowing coverage test tool to see all Dart files

full_coverage Coverage tools like codecov only see the files that were actually triggered by tests. This means that a coverage of 100% can easily be a

Flutterando 2 Mar 18, 2022
A flutter widget that provides pull-down refresh and pull-up load.

flutter_easyrefresh English | 中文 正如名字一样,EasyRefresh很容易就能在Flutter应用上实现下拉刷新以及上拉加载操作,它支持几乎所有的Flutter控件。它的功能与Android的SmartRefreshLayout很相似,同样也吸取了很多三方库的优点。

KnoYo 3.4k Jan 8, 2023
Custom flutter testing CLI tool for individual test runs and group testing

fluttertest Custom flutter testing CLI tool for inidividual test runs or group testing Overview Flutter is a great framework which has helps developer

vi_mi 15 Nov 6, 2022
📖 A Guide for your first pull request

?? A Guide for your first pull request This project has been excluded by Hacktoberfest 2022 ✨ This project will help you to make your first pull reque

Dip Hire 27 Dec 2, 2022
Use the template to create your own repository, complete the project and verify

Proyecto Nivelación MisionTic Usar el template para crear un repositorio propio,

nockturb 0 Dec 20, 2021
Sink - Verify that you're spending more than you can afford

Sink Sink is an app that allows you to track your income and expenses. Current Status Usable Visually bearable Unusable Local App Setup While working

Simonas Viliūnas 85 Jan 3, 2023
The mobile app to verify digitally signed invoices.

Invoice Verif The mobile application for verifying invoices generated by the signed-invoice tool. All verification steps are performed on your termina

Maël Gangloff 3 Oct 18, 2022
GetX Architecture for large scale project, This project include - pagination, pull to refresh, localization, network call and advance error handling

GetX Architecture for large scale project, This project include - pagination, pull to refresh, localization, network call and advance error handling

Wai Han Ko 5 Nov 29, 2022