Home
last modified time | relevance | path

Searched refs:mock (Results 1 – 25 of 1242) sorted by relevance

12345678910>>...50

/external/python/mock/mock/tests/
Dtestmock.py13 import mock
14 from mock import (
20 from mock.mock import _CallList
21 from mock.tests.support import is_instance
76 mock = Mock()
78 self.assertFalse(mock.called, "called not initialised correctly")
79 self.assertEqual(mock.call_count, 0,
81 self.assertTrue(is_instance(mock.return_value, Mock),
84 self.assertEqual(mock.call_args, None,
86 self.assertEqual(mock.call_args_list, [],
[all …]
Dtestmagicmethods.py21 from mock import Mock, MagicMock
22 from mock.mock import _magics
29 mock = Mock()
30 self.assertFalse(hasattr(mock, '__getitem__'))
32 mock.__getitem__ = Mock()
33 self.assertTrue(hasattr(mock, '__getitem__'))
35 del mock.__getitem__
36 self.assertFalse(hasattr(mock, '__getitem__'))
40 mock = MagicMock()
42 del mock.__getitem__
[all …]
Dtesthelpers.py8 from mock import (
12 from mock.mock import _Call, _CallList
31 mock = Mock()
32 mock(ANY)
33 mock.assert_called_with(ANY)
35 mock = Mock()
36 mock(foo=ANY)
37 mock.assert_called_with(foo=ANY)
45 mock = Mock()
46 mock(datetime.now(), foo=datetime.now())
[all …]
/external/mockito/src/test/java/org/mockitousage/matchers/
DMatchersTest.java55 import static org.mockito.Mockito.mock;
66 private IMethods mock = Mockito.mock(IMethods.class); field in MatchersTest
70 when(mock.oneArg(and(eq(false), eq(false)))).thenReturn("0"); in and_overloaded()
71 when(mock.oneArg(and(eq((byte) 1), eq((byte) 1)))).thenReturn("1"); in and_overloaded()
72 when(mock.oneArg(and(eq('a'), eq('a')))).thenReturn("2"); in and_overloaded()
73 when(mock.oneArg(and(eq(1D), eq(1D)))).thenReturn("3"); in and_overloaded()
74 when(mock.oneArg(and(eq(1F), eq(1F)))).thenReturn("4"); in and_overloaded()
75 when(mock.oneArg(and(eq(1), eq(1)))).thenReturn("5"); in and_overloaded()
76 when(mock.oneArg(and(eq(1L), eq(1L)))).thenReturn("6"); in and_overloaded()
77 when(mock.oneArg(and(eq((short) 1), eq((short) 1)))).thenReturn("7"); in and_overloaded()
[all …]
DVarargsTest.java40 private IMethods mock; field in VarargsTest
52 mock.varargs(); in shouldMatchVarArgs_noArgs()
54 verify(mock).varargs(); in shouldMatchVarArgs_noArgs()
60 mock.varargs(); in shouldMatchEmptyVarArgs_noArgsIsNotNull()
62 verify(mock).varargs(isNotNull()); in shouldMatchEmptyVarArgs_noArgsIsNotNull()
68 mock.varargs(); in shouldMatchEmptyVarArgs_noArgsIsNull()
70 verify(mock).varargs(isNull()); in shouldMatchEmptyVarArgs_noArgsIsNull()
76 mock.varargs(); in shouldMatchEmptyVarArgs_noArgsIsNotNullArray()
78 verify(mock).varargs((String[]) isNotNull()); in shouldMatchEmptyVarArgs_noArgsIsNotNullArray()
84 mock.varargs(arg); in shouldMatchVarArgs_oneNullArg_eqNull()
[all …]
DAnyXMatchersAcceptNullsTest.java20 private IMethods mock; field in AnyXMatchersAcceptNullsTest
24 mock = Mockito.mock(IMethods.class); in setUp()
29 when(mock.oneArg((Object) any())).thenReturn("matched"); in shouldAcceptNullsInAnyMatcher()
31 assertEquals(null, mock.forObject(null)); in shouldAcceptNullsInAnyMatcher()
36 when(mock.oneArg((Object) anyObject())).thenReturn("matched"); in shouldAcceptNullsInAnyObjectMatcher()
38 assertEquals(null, mock.forObject(null)); in shouldAcceptNullsInAnyObjectMatcher()
43 when(mock.oneArg(anyString())).thenReturn("0"); in shouldNotAcceptNullInAnyXMatchers()
44 when(mock.forList(anyListOf(String.class))).thenReturn("1"); in shouldNotAcceptNullInAnyXMatchers()
45 when(mock.forMap(anyMapOf(String.class, String.class))).thenReturn("2"); in shouldNotAcceptNullInAnyXMatchers()
46 when(mock.forCollection(anyCollectionOf(String.class))).thenReturn("3"); in shouldNotAcceptNullInAnyXMatchers()
[all …]
/external/python/cpython3/Lib/unittest/test/testmock/
Dtestmagicmethods.py3 from unittest.mock import Mock, MagicMock, _magics
10 mock = Mock()
11 self.assertFalse(hasattr(mock, '__getitem__'))
13 mock.__getitem__ = Mock()
14 self.assertTrue(hasattr(mock, '__getitem__'))
16 del mock.__getitem__
17 self.assertFalse(hasattr(mock, '__getitem__'))
21 mock = MagicMock()
23 del mock.__getitem__
24 self.assertRaises(TypeError, lambda: mock['foo'])
[all …]
Dtestmock.py7 from unittest import mock
8 from unittest.mock import (
52 mock = Mock()
54 self.assertFalse(mock.called, "called not initialised correctly")
55 self.assertEqual(mock.call_count, 0,
57 self.assertTrue(is_instance(mock.return_value, Mock),
60 self.assertEqual(mock.call_args, None,
62 self.assertEqual(mock.call_args_list, [],
64 self.assertEqual(mock.method_calls, [],
68 self.assertNotIn('_items', mock.__dict__,
[all …]
Dtesthelpers.py6 from unittest.mock import (
29 mock = Mock()
30 mock(ANY)
31 mock.assert_called_with(ANY)
33 mock = Mock()
34 mock(foo=ANY)
35 mock.assert_called_with(foo=ANY)
43 mock = Mock()
44 mock(datetime.now(), foo=datetime.now())
46 mock.assert_called_with(ANY, foo=ANY)
[all …]
/external/mockito/src/test/java/org/mockitousage/stubbing/
DStubbingConsecutiveAnswersTest.java20 private IMethods mock; field in StubbingConsecutiveAnswersTest
24 when(mock.simpleMethod()) in should_return_consecutive_values()
29 assertEquals("one", mock.simpleMethod()); in should_return_consecutive_values()
30 assertEquals("two", mock.simpleMethod()); in should_return_consecutive_values()
31 assertEquals("three", mock.simpleMethod()); in should_return_consecutive_values()
32 assertEquals("three", mock.simpleMethod()); in should_return_consecutive_values()
33 assertEquals("three", mock.simpleMethod()); in should_return_consecutive_values()
38 when(mock.simpleMethod()).thenReturn(null, (String[]) null); in should_return_consecutive_values_for_two_nulls()
40 assertNull(mock.simpleMethod()); in should_return_consecutive_values_for_two_nulls()
41 assertNull(mock.simpleMethod()); in should_return_consecutive_values_for_two_nulls()
[all …]
DStubbingWithThrowablesTest.java14 import static org.mockito.Mockito.mock;
41 private LinkedList mock; field in StubbingWithThrowablesTest
50 mock = mock(LinkedList.class); in setup()
51 mockTwo = mock(HashMap.class); in setup()
56 when(mock.add("")).thenThrow(new ExceptionOne()); in throws_same_exception_consecutively()
61 mock.add(""); in throws_same_exception_consecutively()
65 mock.add("1"); in throws_same_exception_consecutively()
70 mock.add(""); in throws_same_exception_consecutively()
77 doThrow(new ExceptionOne()).when(mock).clear(); in throws_same_exception_consecutively_with_doThrow()
82 mock.clear(); in throws_same_exception_consecutively_with_doThrow()
[all …]
DStubbingUsingDoReturnTest.java29 @Mock private IMethods mock; field in StubbingUsingDoReturnTest
37 doReturn("foo").when(mock).simpleMethod(); in should_stub()
38 doReturn("bar").when(mock).simpleMethod(); in should_stub()
40 Assertions.assertThat(mock.simpleMethod()).isEqualTo("bar"); in should_stub()
45 doReturn("foo").when(mock).simpleMethod("foo"); in should_stub_with_args()
46 doReturn("bar").when(mock).simpleMethod(eq("one"), anyInt()); in should_stub_with_args()
48 Assertions.assertThat(mock.simpleMethod("foo")).isEqualTo("foo"); in should_stub_with_args()
49 Assertions.assertThat(mock.simpleMethod("one", 234)).isEqualTo("bar"); in should_stub_with_args()
50 Assertions.assertThat(mock.simpleMethod("xxx", 234)).isEqualTo(null); in should_stub_with_args()
57 doThrow(new FooRuntimeException()).when(mock).voidMethod(); in should_stub_with_throwable()
[all …]
/external/mockito/src/test/java/org/mockitousage/stacktrace/
DModellingDescriptiveMessagesTest.java28 @Mock private IMethods mock; field in ModellingDescriptiveMessagesTest
39 verify(mock); in makeSureStateIsValidatedInTheVeryFirstTestThanksToTheRunner()
44 verify(mock).otherMethod(); in shouldSayWantedButNotInvoked()
49 mock.otherMethod(); in shouldPointOutInteractionsOnMockWhenOrdinaryVerificationFails()
50 mock.booleanObjectReturningMethod(); in shouldPointOutInteractionsOnMockWhenOrdinaryVerificationFails()
52 verify(mock).simpleMethod(); in shouldPointOutInteractionsOnMockWhenOrdinaryVerificationFails()
57 mock.simpleMethod("blah"); in shouldShowActualAndExpected()
58 verify(mock).simpleMethod(); in shouldShowActualAndExpected()
63 mock.simpleMethod(); in shouldSayTooLittleInvocations()
64 verify(mock, times(2)).simpleMethod(); in shouldSayTooLittleInvocations()
[all …]
/external/googletest/googlemock/test/
Dgmock_link_test.h248 Mock mock; in TEST() local
250 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return()); in TEST()
251 mock.VoidFromString(nullptr); in TEST()
256 Mock mock; in TEST() local
259 EXPECT_CALL(mock, StringFromString(_)).WillOnce(Return(&ch)); in TEST()
260 mock.StringFromString(nullptr); in TEST()
265 Mock mock; in TEST() local
267 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return()); in TEST()
268 mock.VoidFromString(nullptr); in TEST()
273 Mock mock; in TEST() local
[all …]
/external/mockito/src/test/java/org/mockitousage/customization/
DBDDMockitoTest.java29 IMethods mock; field in BDDMockitoTest
33 given(mock.simpleMethod("foo")).willReturn("bar"); in should_stub()
35 Assertions.assertThat(mock.simpleMethod("foo")).isEqualTo("bar"); in should_stub()
36 Assertions.assertThat(mock.simpleMethod("whatever")).isEqualTo(null); in should_stub()
41 given(mock.simpleMethod("foo")).willThrow(new SomethingWasWrong()); in should_stub_with_throwable()
44 Assertions.assertThat(mock.simpleMethod("foo")).isEqualTo("foo"); in should_stub_with_throwable()
52 given(mock.simpleMethod("foo")).willThrow(SomethingWasWrong.class); in should_stub_with_throwable_class()
55 Assertions.assertThat(mock.simpleMethod("foo")).isEqualTo("foo"); in should_stub_with_throwable_class()
65 … given(mock.simpleMethod("foo")).willThrow(SomethingWasWrong.class, AnotherThingWasWrong.class); in should_stub_with_throwable_classes()
68 Assertions.assertThat(mock.simpleMethod("foo")).isEqualTo("foo"); in should_stub_with_throwable_classes()
[all …]
/external/mockito/src/test/java/org/mockitousage/jls/
DJLS_15_12_2_5Test.java19 import static org.mockito.Mockito.mock;
55 SingleOverload mock = mock(SingleOverload.class); in with_single_arg() local
57 when(mock.oneArg(isNull())).thenReturn("ok"); in with_single_arg()
59 assertThat(mock.oneArg(null)).describedAs("Most generic method chosen for matcher " + in with_single_arg()
67 SingleOverload mock = mock(SingleOverload.class); in with_single_arg_and_matcher_cast() local
69 when(mock.oneArg((String) isNull())).thenReturn("ok"); in with_single_arg_and_matcher_cast()
71 …assertThat(mock.oneArg(null)).describedAs("Most specific method enforced for matcher via cast").is… in with_single_arg_and_matcher_cast()
76 SingleOverload mock = mock(SingleOverload.class); in with_single_arg_and_null_Object_reference() local
78 when(mock.oneArg(isNull())).thenReturn("ok"); in with_single_arg_and_null_Object_reference()
81 …assertThat(mock.oneArg(arg)).describedAs("Most generic method chosen for matcher").isEqualTo("ok"); in with_single_arg_and_null_Object_reference()
[all …]
/external/google-breakpad/src/testing/test/
Dgmock_link_test.h243 Mock mock; in TEST() local
245 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return()); in TEST()
246 mock.VoidFromString(NULL); in TEST()
251 Mock mock; in TEST() local
254 EXPECT_CALL(mock, StringFromString(_)).WillOnce(Return(&ch)); in TEST()
255 mock.StringFromString(NULL); in TEST()
260 Mock mock; in TEST() local
262 EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return()); in TEST()
263 mock.VoidFromString(NULL); in TEST()
268 Mock mock; in TEST() local
[all …]
/external/mockito/src/test/java/org/mockitousage/
DCompilationWarningsTest.java23 doReturn(null).when(mock(IMethods.class)).objectReturningMethodNoArgs(); in no_warnings_for_most_common_api()
24 doReturn("a", 12).when(mock(IMethods.class)).objectReturningMethodNoArgs(); in no_warnings_for_most_common_api()
25 doReturn(1000).when(mock(IMethods.class)).objectReturningMethodNoArgs(); in no_warnings_for_most_common_api()
26 … doThrow(new NullPointerException()).when(mock(IMethods.class)).objectReturningMethodNoArgs(); in no_warnings_for_most_common_api()
27 …doThrow(new NullPointerException(), new IllegalArgumentException()).when(mock(IMethods.class)).obj… in no_warnings_for_most_common_api()
28 … doThrow(NullPointerException.class).when(mock(IMethods.class)).objectReturningMethodNoArgs(); in no_warnings_for_most_common_api()
30 doAnswer(ignore()).doReturn(null).when(mock(IMethods.class)).objectReturningMethodNoArgs(); in no_warnings_for_most_common_api()
31 … doAnswer(ignore()).doReturn("a", 12).when(mock(IMethods.class)).objectReturningMethodNoArgs(); in no_warnings_for_most_common_api()
32 doAnswer(ignore()).doReturn(1000).when(mock(IMethods.class)).objectReturningMethodNoArgs(); in no_warnings_for_most_common_api()
33 …doAnswer(ignore()).doThrow(new NullPointerException()).when(mock(IMethods.class)).objectReturningM… in no_warnings_for_most_common_api()
[all …]
/external/mockito/src/test/java/org/mockitousage/basicapi/
DMocksSerializationTest.java41 Bar mock = mock(Bar.class, new ThrowsException(new RuntimeException())); in should_allow_throws_exception_to_be_serializable() local
43 serializeAndBack(mock); in should_allow_throws_exception_to_be_serializable()
49 Bar barMock = mock(Bar.class, withSettings().serializable()); in should_allow_method_delegation()
50 Foo fooMock = mock(Foo.class); in should_allow_method_delegation()
60 IMethods mock = mock(IMethods.class, withSettings().serializable()); in should_allow_mock_to_be_serializable() local
63 serializeAndBack(mock); in should_allow_mock_to_be_serializable()
69 IMethods mock = mock(IMethods.class, withSettings().serializable()); in should_allow_mock_and_boolean_value_to_serializable() local
70 when(mock.booleanReturningMethod()).thenReturn(true); in should_allow_mock_and_boolean_value_to_serializable()
73 ByteArrayOutputStream serialized = serializeMock(mock); in should_allow_mock_and_boolean_value_to_serializable()
83 IMethods mock = mock(IMethods.class, withSettings().serializable()); in should_allow_mock_and_string_value_to_be_serializable() local
[all …]
DUsingVarargsTest.java31 @Mock IVarArgs mock; field in UsingVarargsTest
35 when(mock.withStringVarargsReturningString(1)).thenReturn("1"); in shouldStubStringVarargs()
36 when(mock.withStringVarargsReturningString(2, "1", "2", "3")).thenReturn("2"); in shouldStubStringVarargs()
39 doThrow(expected).when(mock).withStringVarargs(3, "1", "2", "3", "4"); in shouldStubStringVarargs()
41 assertEquals("1", mock.withStringVarargsReturningString(1)); in shouldStubStringVarargs()
42 assertEquals(null, mock.withStringVarargsReturningString(2)); in shouldStubStringVarargs()
44 assertEquals("2", mock.withStringVarargsReturningString(2, "1", "2", "3")); in shouldStubStringVarargs()
45 assertEquals(null, mock.withStringVarargsReturningString(2, "1", "2")); in shouldStubStringVarargs()
46 assertEquals(null, mock.withStringVarargsReturningString(2, "1", "2", "3", "4")); in shouldStubStringVarargs()
47 assertEquals(null, mock.withStringVarargsReturningString(2, "1", "2", "9999")); in shouldStubStringVarargs()
[all …]
/external/guava/guava-tests/test/com/google/common/cache/
DForwardingLoadingCacheTest.java38 private LoadingCache<String, Boolean> mock; field in ForwardingLoadingCacheTest
48 mock = createMock(LoadingCache.class); in setUp()
51 return mock; in setUp()
57 expect(mock.get("key")).andReturn(Boolean.TRUE); in testGet()
58 replay(mock); in testGet()
60 verify(mock); in testGet()
64 expect(mock.getUnchecked("key")).andReturn(Boolean.TRUE); in testGetUnchecked()
65 replay(mock); in testGetUnchecked()
67 verify(mock); in testGetUnchecked()
71 expect(mock.getAll(ImmutableList.of("key"))).andReturn(ImmutableMap.of("key", Boolean.TRUE)); in testGetAll()
[all …]
/external/mockito/src/test/java/org/mockito/internal/
DInvalidStateDetectionTest.java42 @Mock private IMethods mock; field in InvalidStateDetectionTest
52 when(mock.simpleMethod()); in shouldDetectUnfinishedStubbing()
55 when(mock.simpleMethod()); in shouldDetectUnfinishedStubbing()
58 when(mock.simpleMethod()); in shouldDetectUnfinishedStubbing()
61 when(mock.simpleMethod()); in shouldDetectUnfinishedStubbing()
64 when(mock.simpleMethod()); in shouldDetectUnfinishedStubbing()
67 when(mock.simpleMethod()); in shouldDetectUnfinishedStubbing()
70 when(mock.simpleMethod()); in shouldDetectUnfinishedStubbing()
102 verify(mock); in shouldDetectUnfinishedVerification()
105 verify(mock); in shouldDetectUnfinishedVerification()
[all …]
/external/mockito/src/test/java/org/mockitousage/verification/
DDescriptiveMessagesWhenVerificationFailsTest.java27 private IMethods mock; field in DescriptiveMessagesWhenVerificationFailsTest
31 mock = Mockito.mock(IMethods.class, "iMethods"); in setup()
37 verify(mock).simpleMethod(); in should_print_method_name()
60 verify(mock).threeArgumentMethod(12, new Foo(), "xx"); in should_print_method_name_and_arguments()
69 mock.varargs(1, 2); in should_print_actual_and_wanted_in_line()
72 verify(mock).varargs(1, 1000); in should_print_actual_and_wanted_in_line()
95 mock.varargs("this is very long string", "this is another very long string"); in should_print_actual_and_wanted_in_multiple_lines()
98 verify(mock).varargs("x", "y", "z"); in should_print_actual_and_wanted_in_multiple_lines()
135 mock.simpleMethod(); in should_print_actual_and_wanted_when_actual_method_name_and_wanted_method_name_are_the_same()
138 verify(mock).simpleMethod(10); in should_print_actual_and_wanted_when_actual_method_name_and_wanted_method_name_are_the_same()
[all …]
DExactNumberOfTimesVerificationTest.java23 private LinkedList<String> mock; field in ExactNumberOfTimesVerificationTest
27 mock = mock(LinkedList.class); in setup()
32 mock.clear(); in shouldDetectTooLittleActualInvocations()
33 mock.clear(); in shouldDetectTooLittleActualInvocations()
35 verify(mock, times(2)).clear(); in shouldDetectTooLittleActualInvocations()
37 verify(mock, times(100)).clear(); in shouldDetectTooLittleActualInvocations()
48 mock.clear(); in shouldDetectTooManyActualInvocations()
49 mock.clear(); in shouldDetectTooManyActualInvocations()
51 verify(mock, times(2)).clear(); in shouldDetectTooManyActualInvocations()
53 verify(mock, times(1)).clear(); in shouldDetectTooManyActualInvocations()
[all …]
/external/mockito/src/test/java/org/mockitousage/strictness/
DStrictnessPerStubbingTest.java26 import static org.mockito.Mockito.mock;
34 @Mock IMethods mock; field in StrictnessPerStubbingTest
44 when(mock.simpleMethod("1")).thenReturn("1"); in potential_stubbing_problem()
45 lenient().when(mock.differentMethod("2")).thenReturn("2"); in potential_stubbing_problem()
48 mock.differentMethod("200"); in potential_stubbing_problem()
54 mock.simpleMethod("100"); in potential_stubbing_problem()
63 .when(mock).simpleMethod(1); in doReturn_syntax()
66 mock.simpleMethod(200); in doReturn_syntax()
69 assertEquals("2", mock.simpleMethod(1)); in doReturn_syntax()
70 assertEquals("3", mock.simpleMethod(1)); in doReturn_syntax()
[all …]

12345678910>>...50