???????gmock????
????gmock??google???????????????в???????gmock?????????????????????????????????漰??????????齻??????????????????mock???????????????????????????в????е???????
???????????????????в????е???????
????1?????????????????????????顣??????????????????????????????????μ??????????????????????????????gmock???????????????????????????????
????2???????????A??飬???A??????????B?????????????B??黹??????????????????gmock??B?????Щ?????????????????A???????????????????
????3???????????豸??????gtest????device???????????????????豸?????ò????????????????gmock??????sdk?????????????????豸????ò???????????
????????gmock??λ??
????gmock??google?????????google???????????????????????????????????????0.2????????“?з???????”??????????gmock???°汾??1.7.0??????????????????????“gmock-1.7.0.zip”??????????£?

????????????????????????gtest??????У??????????????gtest????????????????£?gmock?????gtest??????в?????????gtest?????????????????????????????
???????????????windows?μ?gmock?????????????????msvc????????С?msvc???????????2005??2010????У????????VS2005??VS2010??????????
??????VS2010?????????????????????????????gmock.lib??gmock_maim.lib??gmock_test.ext?????????????gmock.lib?????????????????????????????????????????????
????????gmock??????demo
????????????????????????????????????漰????????????????????????????п?ID??????????????????????????????????????????????д????????????????????????????????
??????????????mock??????????????????д??????????????????????????AccountManager.h ??
????// AccountManager.h
????// the interface of external services which should be mocked
????// ?????mock???????
????#pragma once
????#include <string>
????#include "Account.h"
????class AccountManager
????{
????public:
????//????????????????????
????virtual Account findAccountForUser(const std::string& userId) = 0;
????//????????????????
????virtual void updateAccount(const Account& account) = 0;
????};
????AccountManager???????mock?????????????findAccountForUser???????????????updateAccount???????????????????????mock???????????????????????????????????麯????????????????????????????????????????mock??????????У???????? ????????????
???????????gmock??mock?????AccountManager????????????
????// MockAccountManager?? mock AccountManager with googlemock
????class MockAccountManager : public AccountManager
????{
????public:
????MOCK_METHOD1(findAccountForUser?? Account(const std::string&));
????MOCK_METHOD1(updateAccount?? void(const Account&));
????};
??????MockAccountManager?????????DB??????AccountManager???????MOCK_METHOD1?gmock????塣?????л?????????????壬??MOCK_METHOD0??MOCK_METHOD2...