Skip to content

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

@istolboff

Description

@istolboff

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions