import akka.actor.ActorSystem; import akka.testkit.javadsl.TestKit; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; public class MyActorTest { static ActorSystem system; @BeforeClass public static void setup() { system = ActorSystem.create(); } @AfterClass public static void teardown() { TestKit.shutdownActorSystem(system); system = null; } @Test public void testMyActor() { new TestKit(system) { { MyActor myActor = system.actorOf(MyActor.props(), "myActor"); myActor.tell("Hello", getRef()); expectMsgEquals("World"); } }; } }


上一篇:
下一篇:
切换中文