mardi 19 mars 2019

C++ unittesting NVI pattern using gmocks

does anybody have experience with unittesting C++ interfaces generated with the NVI pattern, using google mocks?

I'd consider the protocol checks (implemented in the NVI part) to be "implementation details" which I wouldn't be interested in when unittesting. I'd rather specify/hint the mock behavior indicating the interface protocol check failed or succeeded, and specify if an exception should be thrown or what kind of return/output values should be returned.

The problem I see with having a "dependency-injectable" virtual part of the NVI pattern is the fact that the NVI part could introduce new dependencies (as implementation detail, rightfully so abstracted away from the client). These new introduced dependencies should also be taken care of in a unittest context (mock them as well in other words) when using the combination of the NVI implementation and the dependency-injected mock as a testdouble.

However since they are part of concrete NVI part implementations this seems impossible.

So how would one deal with such a setup?

Aucun commentaire:

Enregistrer un commentaire