Skip to content

Commit

Permalink
Specify onMissingStub for MockCatRelaxed
Browse files Browse the repository at this point in the history
  • Loading branch information
parlough committed Aug 18, 2023
1 parent 69a6a82 commit bd4387d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ abstract class Callbacks {
Cat,
Callbacks,
], customMocks: [
MockSpec<Cat>(as: #MockCatRelaxed),
MockSpec<Cat>(
as: #MockCatRelaxed,
onMissingStub: OnMissingStub.returnDefault,
),
])
void main() {
late Cat cat;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit bd4387d

Please sign in to comment.