Designing for testability

Andreas Pakulat apaku at gmx.de
Tue Sep 16 11:56:12 UTC 2008


On 16.09.08 07:35:06, Kris Wong wrote:
> > One possibility I can think of currently is providing setters for the
> > controller's and having CorePrivate check if any of the
> > controller's is
> > already set to a valid value before creating a new instance of it.
> >
> > Does somebody have a better idea to this?
> 
> Create a child CoreTest class used in your tests and provide setters in that.

That unfortunately doesn't work, because the subclass has no access to
the actual members of the CorePrivate class. However it could be
possible to do all this by making m_self and the constructor of Core
protected and then making sure that tests call CoreTest::self() before
anything ever calls Core::self(). And of course making all the getters
virtual so a subclass can override them.

This I think would also solve the setup-nongui-core problem, one can
just provide an apropriate core subclass that initializes a custom
uicontroller that simply does nothing.

Andreas
 
-- 
You are capable of planning your future.




More information about the KDevelop-devel mailing list