mardi 31 janvier 2017

Unit tests : mocking a tested function

I know about the basics about test doubles, mocking, etc. but I'm having problems to test the following

void funA(args...) {
    /* do some complicated stuff, using mocked functions */
}

I've written the unit tests for funA, checking the good functions were called (using their mocked implementation).

Now, I want to test this function

void funB(args...) {
    /* do some complicated stuff, and call `funA()` on some situations */
}

How can I be sure my funA function was called from funB? I can't add a fake implementation to funA, I need its production code so it can be tested.

What I am doing now is making sure the mocks that funA is calling are as I expect them to be. But it's not a good method, because it's like I'm testing funA all over again, when I just want to make sure funB does its job.

Aucun commentaire:

Enregistrer un commentaire