jeudi 25 juin 2015

Google Mock Class Constructor with parameters depending on other objects

  class MockBaseClass : public BaseClass
  {

    public:
    // Constructor
    MockBaseClass(MockDep1 * pA)
     :BaseClass( pA)
    {
       mpA = pA;
    }

MockDep1 is a mock for Dep1

BaseClass

BaseClass(Dep1 *pA) { ..... mpX = new X(pA->getCollection()->getA());//crashes }

How can I avoid this situation? I tried to make a mock for X class but I don't know how to use it because the constructor of the Base Class is called anyway.

Aucun commentaire:

Enregistrer un commentaire