mercredi 20 décembre 2017

Understanding cmocka wrapping

I don't get how do I actually use wrapping in real testing. Suppose I have a function:

bool b()
{
     something
}

void a(){
    if(b())
    {
        C();
    }
    else
    {
        d();
    }
}

So, in order to achieve 100% test coverage I need to make function b return both true and false.

And there's two options:

  1. generate huge amount of input data for b in order to force it though both branches.
  2. Mock it.

The problem is that mocking functions defined in the same source file is impossible. And even if I could do so, I wouldn't be able to call this function further on, when I need it to actually do some real work in order to test it's behavior.

So, suppose I have a set of functions defined in the same file and calling each other. What's the valid strategy for testing them in that case?

Aucun commentaire:

Enregistrer un commentaire