EvoSuite / evosuite

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

How does EVOSUITE verify generated tests are executable? #383

Closed jiseongg closed 2 years ago

jiseongg commented 2 years ago

Dear EVOSUITE community,

Hi, I'm a student researching on Java test generation. I'm currently trying to understand the implementation of EVOSUITE.

As far as I know, EVOSUITE first generates test code randomly, which is the sequence of statements (method call, constructor, etc.), and they're passed to the genetic algorithm. However, I think the most of purely randomly generated tests are not executable. My questions are here.

  1. Is there any verification logic that proves generated tests are executable? If so, which part of source code I have to look?
  2. Or, without explicit implementation of the module verifying the executability, is there some rules to guarantee it somehow soundly? (e.g. constructor call should precede method call) If so, which part of source code I have to look?

Thanks in advance for any help you are able to provide.

giograno commented 2 years ago

Hi @jiseongg, if you are interested in how the initial tests are generated, you should have a look at the org.evosuite.testcase.TestFactory class (and in particular, at the insertRandomStatement method). This class is used by all the concrete implementations of org.evosuite.ga.ChromosomeFactory to randomly generate an initial population of solutions.

jiseongg commented 2 years ago

Hi @giograno, thank you for detailed guide! I'll look at the part you said :)