ふくしま

ソフトウェアエンジニア

@GenerateMocksで指定したモッククラスが生成されなかった話

問題

表題の通り、テストコードであるクラスをモックしようとして、@GenerateMocksで指定したのに、コード生成がされなかった。 flutter pub run build_runner build コマンド自体は成功する。

解決方法

[SEVERE] Conflicting outputs were detected and the build is unable to prompt for permission to remove them. 
These outputs must be removed manually or the build can be run with `--delete-conflicting-outputs`.
The outputs are: lib/fuga/hoge.dart

標準出力をよく見ると上記があった。 試しに言われた通りに以下のコマンドを実行してみると、生成された。

flutter pub run build_runner build --delete-conflicting-outputs