I am currently testing an akka application.
I have come across a certain pattern: I want to test that a TestProbe
has received a certain message, modulo some fields.
For example, if the message was:
UserInfo(username: String, score: Int, timestamp: String)
Then I might want to test the username
and score
are as expected, but not care at what time the message was received.
Currently I would like write something like this:
testProbe.expectMsgPF() {
case UserInfo(`username`, `score`, _) =>
}
How could the test probe class be extended so that something like this might be written instead?
testProbe.expectApproxMsg(UserInfo(`username`, `score`, _))
In addition to shortening my code, I'm hoping an answer to this question will further my understanding of the Scala programming language.