-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate spy(), make the default no-mirrors.
- Loading branch information
1 parent
9820ba3
commit dc8ce18
Showing
7 changed files
with
97 additions
and
51 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,5 @@ | ||
@Deprecated('Using spy() is deprecated as we drop dart:mirrors usage') | ||
library mockito.deprecated; | ||
|
||
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 "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
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/deprecated.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(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'); | ||
}); | ||
}); | ||
} |