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

How to get method argument values in ExecutionResult? #341

Closed EhsanMashhadi closed 3 years ago

EhsanMashhadi commented 3 years ago

Hi,

Is there any way to get the method argument values of coveredMethods field of ExecutionResult in getFitness function?

Thanks

apanichella commented 3 years ago

Hi, yes, you need to look at the class ExecutionResult. Assuming you are working at the test case level (e.g., using MOSA or DynaMOSA), a chromosome is an instance of the TestChromosome class.

Assuming you want to check the method covered by each test case, you can use the following method to retrieve all covered data, including covered methods:

chromosome.getLastExecutionResult().getTrace().getCoveredMethods()

where chromosome is an object of the TestChromosome class.

Best, Annibale