Closed baptisteroziere closed 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
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
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 ; } }
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
EvoSuite 1.1.0
Going to generate test cases for class: BINARY_SEARCH_1
Starting Client-0
Connecting to master process on port 7580
Analyzing classpath:
Finished analyzing classpath
Generating tests for class BINARY_SEARCH_1
Test criteria:
Using seed 1618411787359
Starting evolution
Initial Number of Goals in DynaMOSA = 9 / 105 [Progress:==============================100%] [Cov:================================> 93%]
Search finished after 11s and 209 generations, 96184 statements, best individual has fitness: 3.0 [MASTER] 14:49:59.598 [logback-1] WARN TimeController - Phase SEARCH lasted too long, 1 seconds more than allowed.
Minimizing test suite
Going to analyze the coverage criteria
Coverage analysis for criterion LINE
Coverage of criterion LINE: 100%
Total number of goals: 9
Number of covered goals: 9
Coverage analysis for criterion BRANCH
Coverage of criterion BRANCH: 100%
Total number of goals: 7
Number of covered goals: 7
Coverage analysis for criterion EXCEPTION
Coverage of criterion EXCEPTION: 100%
Total number of goals: 2
Number of covered goals: 2
Coverage analysis for criterion WEAKMUTATION
Coverage of criterion WEAKMUTATION: 99%
Total number of goals: 75
Number of covered goals: 74
Coverage analysis for criterion OUTPUT
Coverage of criterion OUTPUT: 100%
Total number of goals: 3
Number of covered goals: 3
Coverage analysis for criterion METHOD
Coverage of criterion METHOD: 100%
Total number of goals: 2
Number of covered goals: 2
Coverage analysis for criterion METHODNOEXCEPTION
Coverage of criterion METHODNOEXCEPTION: 100%
Total number of goals: 2
Number of covered goals: 2
Coverage analysis for criterion CBRANCH
Coverage of criterion CBRANCH: 100%
Total number of goals: 7
Number of covered goals: 7
Generated 5 tests with total length 16
Resulting test suite's coverage: 94% (average coverage for all fitness functions)
Generating assertions
Resulting test suite's mutation score: 91%
Compiling and checking tests
Writing tests to file
Writing JUnit test case 'BINARY_SEARCH_1_ESTest' to evosuite-tests
Done!
Computation finished [MASTER] 14:50:04.001 [main] ERROR RuntimeVariable - Obtained invalid goal count: covered 106 out of 105 [MASTER] 14:50:04.001 [main] ERROR SearchStatistics - Not going to write down statistics data, as some data is invalid [MASTER] 14:50:04.102 [main] ERROR TestGeneration - failed to write statistics data
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