0; int count() = 0; }; class ConcreteData : public Data {...}; class FakeData : public Data {...}; class Processor { public: Processor(); void SetData(Data* data) { d_ = d; }
DbRecordTests.cpp #include "Pre.h" #include "DbRecord.h" class MysqlStub { ... }; ... // Pre.h -> Different in tests // than in production code #define Mysql MysqlStub Legacy Code
// Option 3: Add testing functions // Option 4: Make some friends :) class MyClass { private: // Google Test macro FRIEND_TEST(MyClassTest, MyMethod); };