EvoSuite / evosuite

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

Evosuite not initializing the Akka actor class #235

Open rajuIVL opened 6 years ago

rajuIVL commented 6 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?

Generate test cases for Akka Actors.

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. Create a class which extends akka.actor.AbstractActor
  2. Generate test for class which extends akka.actor.AbstractActor Example:

    import akka.actor.AbstractActor; public final class TestClassDemo extends AbstractActor{ @Override public Receive createReceive() { // TODO Auto-generated method stub return null; } }

EvoSuite Arguments

Please provide the whole EvoSuite commmand you executed (if relevant) -projectCP target\classes -class com.test.TestClassDemo

Current Result

Please describe here below the current result you got (if relevant) [if relevant, include a screenshot]

Generated the test case as below. ( initialization of actor failed. )

public class TestClassDemo_ESTest extends TestClassDemo_ESTest_scaffolding {

@Test(timeout = 4000) public void test1() throws Throwable { TestClassDemo testClassDemo0 = null; try { testClassDemo0 = new TestClassDemo(); fail("Expecting exception: RuntimeException");

  } catch(RuntimeException e) {
     //
     // You cannot create an instance of [com.bt.TestClassDemo] explicitly using the constructor (new). You have to use one of the 'actorOf' factory methods to create a new actor. See the documentation.
     //
     verifyException("akka.actor.ActorInitializationException$", e);
  }

}

Expected result

Please describe here below what should be the expected behavior (if relevant)

Successful test case creation.

Additional info

Please add any information of interest here below please help me to initialize the actor class.

gofraser commented 5 years ago

Thanks for reporting this. What do you expect EvoSuite to do? The class has a constructor, EvoSuite calls it - it has no way of knowing that this is not the preferred way of doing it.