Created
January 26, 2021 11:33
-
-
Save svarlet/337c0d3234cc3ba67c7d96adf788c092 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:test/test.dart'; | |
import 'package:mocktail/mocktail.dart'; | |
class Demo { | |
void doSomething(int i) { | |
i + i; | |
} | |
} | |
class DemoDouble extends Mock implements Demo {} | |
class UserOfDemo { | |
final Demo _demo; | |
UserOfDemo(this._demo); | |
void methodThatDependsOnDemo() { | |
_demo.doSomething(1); | |
} | |
} | |
void main() { | |
test('it calls doSomething()', () { | |
final _demo = DemoDouble(); | |
final sut = UserOfDemo(_demo); | |
sut.methodThatDependsOnDemo(); | |
verify(_demo).called(#doSomething).withArgs(positional: [1]); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following should work: