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

Support target_method functioning for MutationFactory #435

Open zzctmac opened 1 year ago

zzctmac commented 1 year ago

As shown in the issue, A crash happens when we use the target_method functioning with DynaMOSA. This is because: 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, following the way of other criterion factories.

jose commented 1 year ago

Hi @zzctmac,

Thanks for taking the time to contribute to this project. Before I go ahead and merge it, I'm wondering whether we would need to replicate this pull request to any other factory class.

-- Best, Jose

zzctmac commented 1 year ago

@jose

Yes, that would be better. But I am sure that only the mutation criterion lacks this function among the default eight criteria.

jose commented 1 year ago

Thanks. Any chance you could augment the TargetMethodListSystemTest class with a few more test cases that would exercise this on each of the default criteria?

zzctmac commented 1 year ago

Ok, good idea. Give me some time

zzctmac commented 1 year ago

Hello @jose, I have created tests for checking all default criteria.