lundi 4 avril 2016

Skip inner method calls in unit testing

Let's say, I have methods A, B, C and D.

public bool A (int foo)
{
    bool result = false;
    if (foo > 0)
        result = B();
    else result = C();
    D(foo);
    return result;
}

I want to write a unit test for A, with calling B or C, but want to skip the D call (because it is a method using external services). Is it possible to skip the D call using some attributes? Or mock the D, substituting it with some fake service?

Aucun commentaire:

Enregistrer un commentaire