Lines Matching refs:mock
6 real objects entirely. A **mock object** implements the same interface as a real
11 It is easy to confuse the term *fake objects* with mock objects. Fakes and mocks
23 to remember is that a mock allows you to check the *interaction* between itself
28 cool) for creating mock classes and using them. It does to C++ what
34 mock, and they will expand to the implementation of your mock class;
35 2. next, you create some mock objects and specify its expectations and behavior
37 3. then you exercise code that uses the mock objects. gMock will catch any
42 While mock objects help you remove unnecessary dependencies in tests and make
50 * The knowledge you gained from using one mock doesn't transfer to the next
53 In contrast, Java and Python programmers have some fine mock frameworks (jMock,
75 * You want to "mock out" your dependencies, except that they don't have mock
129 tests, you can use a mock implementation instead. This allows you to easily
139 some nice people. If, however, you find yourself in the position to write a mock
149 [mock non-virtual methods using templates](gmock_cook_book.md#MockingNonVirtualMethods),
160 * Repeat until all virtual functions you want to mock are done. (It goes
182 You don't need to define these mock methods somewhere else - the `MOCK_METHOD`
187 When you define a mock class, you need to decide where to put its definition.
193 Generally, you should not mock classes you don't own. If you must mock such a
194 class owned by others, define the mock class in `Foo`'s Bazel package (usually
209 Once you have a mock class, using it is easy. The typical work flow is:
214 2. Create some mock objects.
218 googletest assertions. If a mock method is called more than expected or with
220 5. When a mock is destructed, gMock will automatically check whether all
226 #include "path/to/mock-turtle.h"
259 **Tip 2:** If your mock objects are never deleted, the final verification won't
266 **Important note:** gMock requires expectations to be set **before** the mock
268 between calls to `EXPECT_CALL()` and calls to the mock functions, and do not set
269 any expectations on a mock after passing the mock to an API.
283 The key to using a mock object successfully is to set the *right expectations*
292 In gMock we use the `EXPECT_CALL()` macro to set an expectation on a mock
302 The macro has two arguments: first the mock object, and then the method and its
348 When a mock function takes arguments, we may specify what arguments we are
434 Remember that a mock object doesn't really have a working implementation? We as
438 First, if the return type of a mock function is a built-in type or a pointer,
441 addition, in C++ 11 and above, a mock function whose return type is
446 Second, if a mock function doesn't have a default action, or the default action
501 Instead of returning 100, 101, 102, ..., consecutively, this mock function will
528 realistically, you'll specify expectations on multiple mock methods which may be
529 from multiple mock objects.
531 By default, when a mock method is invoked, gMock will search the expectations in
553 expectations in a mock object's constructor or the test fixture's set-up phase
554 and then customize the mock by writing more specific expectations in the test
607 Now let's do a quick quiz to see how well you can use this mock stuff already.
695 A mock object may have many methods, and not all of them are that interesting.