I\'m interested to know about how to test Akka Actor functionality, by mocking some methods (substitute real object\'s/actor\'s method implementation by moc
To mock an actor is easier through the TestActorRef. You can use this code :
static ActorSystem system = ActorSystem.create();
static Props propsSome = Props.create(MockedResultActor.class);
TestActorRef refMockedResultActor= TestActorRef.create(
system, propsSome, "testA");
// Mocking an actor class and returning our reference actor
PowerMockito.mockStatic(ClassToBeMocked.class);
Mockito.when(ClassToBeMocked.getToBeMockedMethod())
.thenReturn(refMockedResultActor);
Note: ClassToBeMocked--Its a class you want to mock. MockedResultActor -- Its a class you want to return after mocking. This can be run using JunitTest after implementing basic configuration of mocking in your class. Code given here is specific to akka actor in java only.