Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Generate Unit test

sunboy Posts: 4

I have a question.
when parasoft generate test for input argument.what is
the procedure of generate values to test argument.for example consider func foo1()

int foo1(int x)

if (x < 10)
return 1;
else if (x >10 and x < 20 )
return 2;
else if ( x > 20 )
return 3;
else return 0;


for test x values that may be generate is :
0,1,-1,9,10,11,19,20,21,max int,min int
this number shows that parasoft understand desicion condition and select approprate number to test boundry value.
now , if we have foo2():

int foo1(float f)

if (f < 2.75)
return -1;
else if (f >2.75 and f < 6.75 )
return 0;
else if ( f > 10.25 )
return 1;
else return -2;

in this example the values that generate by parasoft is :
we expect that values like 2.8,2.6,6.74,6.73,10.24,10.26,and so on generate.
please explain that parasoft can generate this range of value for float and so on variables ?
tanks a lot


  • Mirek
    Mirek Posts: 140 admin

    Hello @sunboy

    For the source example with floating-point values, you should see test cases containing values used inside conditions. With floating-point values, heuristics work slightly differently due to floating-point comparison specifics.

    Please double-check the limit of generated test cases in the test configuration's Generation->General->Max number of generated test cases (per. function).

    If this value is low, like 4 or 6, you may not see these additional heuristics-based test cases.

    Also, please check the test configuration's Generation->Test Case-> Use heuristic values for input parameters. It should be enabled.