├── .gitignore ├── lib ├── test_cov_console.dart └── src │ ├── print_cov_constants.dart │ ├── parser_constants.dart │ ├── parser.dart │ └── print_cov.dart ├── pubspec.yaml ├── example ├── .metadata ├── .gitignore ├── test │ └── widget_test.dart ├── README.md ├── pubspec.yaml └── lib │ └── main.dart ├── LICENSE ├── CHANGELOG.md ├── test ├── parser_test.dart └── test_cov_console_test.dart ├── bin └── test_cov_console.dart └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .dart_tool/ 3 | .packages 4 | .pub/ 5 | build/ 6 | # Remove the following pattern if you wish to check in your lock file 7 | pubspec.lock 8 | 9 | # Directory created by dartdoc 10 | doc/api/ 11 | 12 | # Editors 13 | .idea 14 | lcov.info 15 | -------------------------------------------------------------------------------- /lib/test_cov_console.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021, DKatalis. All rights reserved. Use of this source code 2 | // is governed by a BSD-style license that can be found in the LICENSE file. 3 | 4 | library test_cov_console; 5 | 6 | export 'src/print_cov.dart'; 7 | export 'src/parser.dart'; 8 | export 'src/parser_constants.dart'; 9 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: test_cov_console 2 | description: Command line utility to read lcov.info and print the coverage report to console. 3 | version: 0.2.2 4 | homepage: https://github.com/DigitalKatalis/test_cov_console 5 | 6 | environment: 7 | sdk: '>=2.12.0 <3.0.0' 8 | 9 | executables: 10 | test_cov_console: 11 | 12 | dev_dependencies: 13 | test: 14 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 78910062997c3a836feee883712c241a5fd22983 8 | channel: unknown 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /lib/src/print_cov_constants.dart: -------------------------------------------------------------------------------- 1 | class PrintCovConstants { 2 | static const fileLen = 45; 3 | static const percentLen = 9; 4 | static const uncoverLen = 19; 5 | static const hundred = '100.00'; 6 | static const zero = '0'; 7 | static const comma = ','; 8 | static const zeroDotZeros = '0.00 '; 9 | static const dart = 'dart'; 10 | static const slash = '/'; 11 | static const bSlash = '\\'; 12 | static const dash = '-'; 13 | static const emptyString = ''; 14 | static const space = ' '; 15 | static const colon = ':'; 16 | static const dot = '.'; 17 | static const dot3 = '...'; 18 | 19 | // lcov.info 20 | static const DA = 'DA'; 21 | static const SF = 'SF'; 22 | static const LF = 'LF'; 23 | static const LH = 'LH'; 24 | static const FNF = 'FNF'; 25 | static const FNH = 'FNH'; 26 | static const BRF = 'BRF'; 27 | static const BRH = 'BRH'; 28 | static const BRDA = 'BRDA'; 29 | static const endOfRecord = 'end_of_record'; 30 | 31 | // literal 32 | static const noUnitTesting = 'no unit testing'; 33 | static const allFiles = 'All files with unit testing'; 34 | static const file = 'File'; 35 | static const branch = '% Branch '; 36 | static const functions = '% Funcs '; 37 | static const lines = '% Lines '; 38 | static const unCovered = 'Uncovered Line #s '; 39 | } 40 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | Given here an example project that generated using Android Studio => File => New => new Flutter project. 4 | 5 | ## Project Explanation 6 | 7 | There is no changes on this project since generated, 8 | the only change is adding test_cov_console lib to pubspec.yaml. 9 | ``` 10 | dev_dependencies: 11 | flutter_test: 12 | sdk: flutter 13 | test_cov_console: ^0.2.2 14 | ``` 15 | 16 | ## How to run 17 | ### run the following command to make sure all flutter library is up-to-date 18 | ``` 19 | flutter pub get 20 | Running "flutter pub get" in coverage... 0.5s 21 | ``` 22 | ### run the following command to generate lcov.info on coverage directory 23 | ``` 24 | flutter test --coverage 25 | 00:02 +1: All tests passed! 26 | ``` 27 | ### run the tool to generate report from lcov.info 28 | ``` 29 | flutter pub run test_cov_console 30 | ---------------------------------------------|---------|---------|---------|-------------------| 31 | File |% Branch | % Funcs | % Lines | Uncovered Line #s | 32 | ---------------------------------------------|---------|---------|---------|-------------------| 33 | lib\ | | | | | 34 | main.dart | 100.00 | 100.00 | 92.59 | 3,4| 35 | ---------------------------------------------|---------|---------|---------|-------------------| 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021, DKatalis. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.2.2 - 13 Mar 2022 2 | 3 | * Add --include option to print particular files only 4 | 5 | ## 0.2.1 - 9 Mar 2022 6 | 7 | * Fixed total coverage when using -e 8 | 9 | ## 0.2.0 - 22 Jan 2022 10 | 11 | * Null safety implementation 12 | 13 | ## 0.1.5 - 7 Nov 2021 14 | 15 | * Fixed duplicate directory on multi option 16 | * Add --line option to print lines coverage only 17 | 18 | ## 0.1.4 - 25 Oct 2021 19 | 20 | * Remove flutter_test dev_dependency. 21 | 22 | ## 0.1.3 - 23 Oct 2021 23 | 24 | * Fixed percentage calculation. 25 | 26 | ## 0.1.2 - 23 Oct 2021 27 | 28 | * Add new features: 29 | -i to not print any file without unit testing 30 | -t to print the total coverage only 31 | -p to print passed/failed of the total coverage only 32 | 33 | ## 0.1.1 - 13 Oct 2021 34 | 35 | * Support for output to CSV file 36 | 37 | ## 0.1.0 - 10 Oct 2021 38 | 39 | * Support for multiple lcov.info files 40 | 41 | ## 0.0.10 - 10 Oct 2021 42 | 43 | * Fixed un-sorted directory issue. 44 | 45 | ## 0.0.9 - 9 Oct 2021 46 | 47 | * Fixed duplicate issue. 48 | 49 | ## 0.0.8 - 24 Sep 2021 50 | 51 | * Fixed some minor issue and documentation. 52 | 53 | ## 0.0.7 - 17 Aug 2021 54 | 55 | * Remove lib dependency. 56 | 57 | ## 0.0.6 - 20 May 2021 58 | 59 | * Fixed minor issue on github repository link. 60 | 61 | ## 0.0.5 - 17 May 2021 62 | 63 | * Add parameter to exclude files without unit testing that contains some strings 64 | 65 | ## 0.0.4 - 16 May 2021 66 | 67 | * Print all dart files, not only that reported on lcov.info (has unit test file) 68 | * Print total coverage for all files with unit testing. 69 | 70 | ## 0.0.3 - 15 May 2021 71 | 72 | * Add example project 73 | * Add simple documentation 74 | 75 | ## 0.0.2 - 14 May 2021 76 | 77 | * Fixed typo issue. 78 | 79 | ## 0.0.1 - 14 May 2021 80 | 81 | * Initial code 82 | -------------------------------------------------------------------------------- /test/parser_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:test/test.dart'; 2 | import 'package:test_cov_console/test_cov_console.dart'; 3 | 4 | var log = []; 5 | 6 | void main() { 7 | group('Parser', () { 8 | const result = '{file: test/test.dart, exclude: [string1, string2]}'; 9 | const singleValue = '{csv: csv, multi: multi}'; 10 | test('should return {} for no input', () async { 11 | final args = Parser([]).parse(); 12 | expect(args.toString(), '{}'); 13 | }); 14 | 15 | test('should return options list for -