EvoSuite / evosuite

EvoSuite - automated generation of JUnit test suites for Java classes
http://www.evosuite.org
GNU Lesser General Public License v3.0
832 stars 341 forks source link

Covered_Goals > Total_Goals on some examples #347

Closed baptisteroziere closed 3 years ago

baptisteroziere commented 3 years ago

Context

I am trying to generate some tests for one of my classes and there seems to be a bug in the Covered_Goals count. It is strictly larger than the number of goals and it makes EvoSuite fail to write the statistics data.

Steps to Reproduce

  1. Write the following class in BINARY_SEARCH_1.java
    
    import java.util.*;
    import java.util.stream.*;
    import java.lang.*;
    import javafx.util.Pair;

public class BINARY_SEARCH_1{ int binarySearch ( int arr [ ] , int x ) { int l = 0 , r = arr . length ; while ( l <= r ) { int m = l + ( r - l ) / 2 ; if ( arr [ m ] == x ) return m ; if ( arr [ m ] < x ) l = m + 1 ; else r = m - 1 ; } return - 1 ; } }

2. Compile `javac BINARY_SEARCH_1.java`
3. Run EvoSuite (see arguments below)

### EvoSuite Arguments

java -jar evosuite-1.1.0.jar -class BINARY_SEARCH_1 -Doutput_variables=configuration_id,TARGET_CLASS,criterion,Total_Goals,Covered_Goals -projectCP=. -Dsearch_budget=10


### Current Result
EvoSuite fails because 106 goals are covered out of 105. Here is the terminal output:

Expected result

I expected EvoSuite to run successfully and write the statistics to a file. I expected Covered_Goals <= Total_Goals.

Additional info

I downloaded the evosuite jar today using this link https://github.com/EvoSuite/evosuite/releases/download/v1.1.0/evosuite-1.1.0.jar

VoglSebastian commented 3 years ago

I haven't tried this with your example, but i think this issue is already fixed in the current master branch and should be fixed in the next version. If this is a critical issue for you, i recommend cloning the current repository and building it locally: mvn -DskipTests clean package The jar-file would be in ./master/target/evosuite-master-1.1.1-SNAPSHOT.jar