scala - akka Actor unit testing using testkit -


there many examples of using akka-testkit when actor being tested responding ask:

//below code copied example link val actorref = testactorref(new myactor) // hypothetical message stimulating '42' answer val future = actorref ? say42 val success(result: int) = future.value.get result must be(42) 

but have actor not respond sender; instead sends message separate actor. simplified example being:

class passthroughactor(sink : actorref) {   def receive : receive = {     case _ => sink ! 42   } } 

testkit has suite of expectmsg methods cannot find examples of creating test sink actor expect message within unit test.

is possible test passthroughactor?

thank in advance consideration , response.

as mentioned in comments can use testprobe solve this:

val sink = testprobe() val actorref = testactorref(props(new passthroughactor(sink.ref)))  actorref ! "message"  sink.expectmsg(42) 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -