ジョインさせていただいているチームでFlutterアプリを開発しているんですが Codecov を導入していて、ローカルCLI上でコマンド叩いてカバレッジレポートを生成しようとすると genhtml: command not found
と出て色々調べてもあまり何も出てこなかったのでメモ!
flutter test --coverage
genhtml coverage/lcov.info -o coverage/html
とやると
genhtml: command not found
と出たので最初$PATHが通っていないのかな?と思っていたのですが、そもそも lcov
が入っていないことがわかったので早速インストール
HomebrewでインストールするのでHomebrewが入っていない場合は下記のコマンドを実行してください。
- Homebrewインストール
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
画面でパスワードの入力を求められた場合は、Macのユーザーパスワードを入力して続行してください。そして、コマンドが完了するまで待ちます。
完了したら、lcovをHomebrewでインストール
brew install lcov
以上で完了なので下記を実行するとカバレッジレポートがブラウザ(Chrome.app)で表示されます。
※Chrome.app以外をお使いの場合は /Applications/Google Chrome.app
の部分を書き換えてください。
flutter test --coverage
genhtml coverage/lcov.info -o coverage/html
open -a '/Applications/Google Chrome.app' coverage/html/index.html
開発環境
Mac OS Catelina 10.15.4