-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from matanlurey/flip_api_defaults
Move all mirrors-based API to mirrors.dart
- Loading branch information
Showing
9 changed files
with
92 additions
and
58 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'mockito.dart'; | ||
export 'src/spy.dart' show spy; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,29 @@ | ||
export 'mockito_no_mirrors.dart'; | ||
export 'src/spy.dart' show spy; | ||
export 'src/mock.dart' | ||
show | ||
Mock, | ||
named, | ||
|
||
// -- setting behaviour | ||
when, | ||
any, | ||
argThat, | ||
captureAny, | ||
captureThat, | ||
typed, | ||
Answering, | ||
Expectation, | ||
PostExpectation, | ||
|
||
// -- verification | ||
verify, | ||
verifyInOrder, | ||
verifyNever, | ||
verifyNoMoreInteractions, | ||
verifyZeroInteractions, | ||
VerificationResult, | ||
Verification, | ||
|
||
// -- misc | ||
clearInteractions, | ||
reset, | ||
logInvocations; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,4 @@ | ||
export 'src/mock.dart' | ||
show | ||
Mock, | ||
named, | ||
@Deprecated('Import "package:mockito/mockito.dart" instead.') | ||
library mockito.mockito_no_mirrors; | ||
|
||
// -- setting behaviour | ||
when, | ||
any, | ||
argThat, | ||
captureAny, | ||
captureThat, | ||
typed, | ||
Answering, | ||
Expectation, | ||
PostExpectation, | ||
|
||
// -- verification | ||
verify, | ||
verifyInOrder, | ||
verifyNever, | ||
verifyNoMoreInteractions, | ||
verifyZeroInteractions, | ||
VerificationResult, | ||
Verification, | ||
|
||
// -- misc | ||
clearInteractions, | ||
reset, | ||
logInvocations; | ||
export 'mockito.dart'; |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:mockito/src/mock.dart' show resetMockitoState; | ||
import 'package:mockito/mirrors.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import 'mockito_test.dart' show MockedClass, RealClass; | ||
|
||
void main() { | ||
RealClass mock; | ||
|
||
setUp(() { | ||
mock = new MockedClass(); | ||
}); | ||
|
||
tearDown(() { | ||
// In some of the tests that expect an Error to be thrown, Mockito's | ||
// global state can become invalid. Reset it. | ||
resetMockitoState(); | ||
}); | ||
|
||
group("spy", () { | ||
setUp(() { | ||
mock = spy/*<RealClass>*/(new MockedClass(), new RealClass()); | ||
}); | ||
|
||
test("should delegate to real object by default", () { | ||
expect(mock.methodWithoutArgs(), 'Real'); | ||
}); | ||
test("should record interactions delegated to real object", () { | ||
mock.methodWithoutArgs(); | ||
verify(mock.methodWithoutArgs()); | ||
}); | ||
test("should behave as mock when expectation are set", () { | ||
when(mock.methodWithoutArgs()).thenReturn('Spied'); | ||
expect(mock.methodWithoutArgs(), 'Spied'); | ||
}); | ||
}); | ||
} |