Akka's TestProbe expectMsg to match if expected message is among sent -


i have test particular actor. actor depends on other actors, use testprobe() test in isolation. problem is, receive more messages interested in testing @ particular test. example:

val = testprobe() val b = testprobe() val actor = testactorref(new myactor(a.ref, b.ref))  actor ! message(1, 2)  b.expectmsg(3) 

the test fails, because while creating myactor sends kind of "registration" message ones passed in constructor.

the message 3 arrives eventually, assertion fails - not first message arrive. avoid asserting more messages need test - can change, etc, not scope of particular test anyway.

as testprobe not contain such methods - suspect there may wrong test setup (or rather project architecture then). see there many methods fishformessage require explicit time parameters seems irrelevant whole test purely synchronous.

is there way accomplish such test desired message among received? if not, how can setup can improved easy testable?

the fishformessage fits. these assertions including expectmsg asynchronous. expectmsg uses preconfigured timefactor timeout.

testactorref guarantees callingthreaddispatcher used send messages , execute futures (if use dispatcher test actor), act sequentially til they're use context.dispatcher. nothing stops code inside myactor using dispatcher send response, checks still should asynchronous - can't rid of that.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -