From bd4387d3c27b058ec597f6f4e411cac94aea82c0 Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Thu, 17 Aug 2023 23:08:36 -0500 Subject: [PATCH] Specify onMissingStub for MockCatRelaxed --- example/example.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/example/example.dart b/example/example.dart index 07e7b8d0..27d7d6e7 100644 --- a/example/example.dart +++ b/example/example.dart @@ -33,7 +33,10 @@ abstract class Callbacks { Cat, Callbacks, ], customMocks: [ - MockSpec(as: #MockCatRelaxed), + MockSpec( + as: #MockCatRelaxed, + onMissingStub: OnMissingStub.returnDefault, + ), ]) void main() { late Cat cat; @@ -231,7 +234,10 @@ void main() { // You can call it without stubbing. cat.sleep(); - // Returns null unless you stub it. + // Non-null properties and return values return reasonable defaults. + expect(cat.lives, 0); + + // Nullable properties and return values return null unless you stub it. expect(cat.sound(), null); expect(cat.eatFood('Milk'), null);