VSharp icon indicating copy to clipboard operation
VSharp copied to clipboard

Tests generated for a public method do not cover branches in methods that are called from the method being analyzed

Open istolboff opened this issue 1 year ago • 0 comments

Let's say I have the following class with a single method:

public static class C
{
    public static int M(int v1, int v2)
    { 
        if (v1 < v2) 
        { 
           return 1; 
        } 
        else 
        { 
            return -1; 
        } 
   }
}

VSharp.Runner, if asked to generate unit tests for this method, will absolutely correctly generate 2 such tests.

VSharp.Runner --type Sut.C Sut.dll --strat BFS --render-tests --output ..\generated\Sut.Tests

BUT, if I move the branching logic into another class, like this:

public static class C
{
    public static int M(int v1, int v2) =>
          C1.MImpl(v1, v2);
}

public static class C1
{
    public static int MImpl(int v1, int v2)
    { 
        if (v1 < v2) 
        { 
           return 1; 
        } 
        else 
        { 
            return -1; 
        } 
   }
}

then a single test will be generated for the methid M of class C. Looks like VSharp.Runner does not try to investigate the code that resides in the methods that are called from the method that's being processed. Or am I just doing something wrong?

Thanks!

istolboff avatar Apr 22 '25 17:04 istolboff