October 2013
Intermediate to advanced
368 pages
9h 20m
English
Mock tools such as Google Mock, CppUMock, or Hippo Mocks simplify your effort to define mocks and set up expectations. You’ll learn how to use Google Mock in this section.
Let’s test-drive
summaryDescription
again. We’ll need to mock the HTTP methods
get
and
initialize
.
| c5/7/Http.h | |
| | virtual ~Http() {} |
| | virtual void initialize() = 0; |
| | virtual std::string get(const std::string& url) const = 0; |
The first step in using the mock support built into Google Mock is to create a derived class that declares mock methods. Google Mock allows us to define the HttpStub derivative succinctly.
| c5/7/PlaceDescriptionServiceTest.cpp | |
| | class HttpStub: public Http { |
| | public: |
| * | MOCK_METHOD0(initialize, ... |
Read now
Unlock full access