EvoSuite / evosuite

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

ERROR ClientNodeImpl when setting -Dtarget_method or -Dtarget_method_list with DynaMOSA #429

Open biabs1 opened 2 years ago

biabs1 commented 2 years ago

Context

Please provide below a detailed introduction to the issue itself, and describe what you were doing when the issue happened. Or, what do you want to achieve? EvoSuite properly generates tests for the entire class with DynaMOSA. However, when setting the -Dtarget_method or -Dtarget_method_list args, I get a ClientNodeImpl ERROR, as shown bellow. On the hand, when I use the Whole test suite generator algorithm instead of DynaMOSA, everything works.

Steps to Reproduce

Please break down here below all the needed steps to reproduce the issue. [If possible, please upload an example of the project you are generating tests for.]

  1. Download the Colt 1.2.0 jar file (https://mvnrepository.com/artifact/colt/colt/1.2.0)
  2. Download EvoSuite
  3. Run the following command

EvoSuite Arguments

Please provide the whole EvoSuite commmand you executed (if relevant) java -jar evosuite-1.2.0.jar -Dtarget_method_list="moment(ID)D" -class hep.aida.bin.DynamicBin1D -projectCP colt-1.2.0.jar

Current Result

Please describe here below the current result you got (if relevant) [if relevant, include a screenshot] Screenshot from 2022-08-10 13-33-53

Expected result

Please describe here below what should be the expected behaviour (if relevant) Tests being generated or, at least, no errors.

Additional info

Please add any information of interest here below I get the same problem when generating tests for different methods from the same project (Colt-1.2.0) or different projects.

zzctmac commented 1 year ago

I am interested in this problem. So far, I have found that this bug is caused by the source code implementing the Mutation Fitness function. So, if you do not need mutation testing, you can nominate the criteria you need, such as Branch coverage by -criterion=BRANCH. But this is an ad-hoc solution. I am still trying to solve this problem.

By the way, I made a small test case reproducing this problem: https://github.com/zzctmac/evosuite/blob/e6318fc608ed865f6980eba36bc184d317dd5732/master/src/test/java/org/evosuite/basic/TargetMethodListSystemTest.java#L21

zzctmac commented 1 year ago

I may find the reason. To implement target_method_list, the developers select the target methods' fitness function in Factory class family, such as branch coverage.

  1. But the developers do not implement this functioning for the Mutation criterion.
  2. As a result, all mutation fitness functions are added to the genetic algorithms.
  3. When the GA is DynaMOSA, it dynamically selects goals by analyzing the dependence relationships among all goals. When DynaMOSA tries to analyze the relationship between branch fitness functions and a mutation fitness function that are not in the target method, the crash happens since branch fitness functions are not added to genetic algorithms.

To fix it, I made a slight change in MutationFactory. This change can pass the above test.