> For the complete documentation index, see [llms.txt](https://cordea.gitbook.io/flutter-test-mockito-recipes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cordea.gitbook.io/flutter-test-mockito-recipes/mock-default-behavior.md).

# Error の代わりに null を返す Mock の作成

具体的な使い所が思いつかない程度に使用頻度が低いものですが、tracking など、仕様上影響はないためデフォルトの返り値が欲しいときに使うことがあるかもしれません。

## Recipe

### customMocks

以下のように定義し、`MockTrackerRelaxed` を使用します。

```dart
@GenerateMocks([
  Tracker,
], customMocks: [
  MockSpec<Tracker>(
    as: #MockTrackerRelaxed,
    returnNullOnMissingStub: true,
  )
])
void main() {
}
```
