0
我目前正在測試akka應用程序。 我碰到過某種模式:我想測試一個TestProbe
已經收到了某個消息,以某些字段爲模。akka:測試郵件模數
例如,如果消息是:
UserInfo(username: String, score: Int, timestamp: String)
然後,我可能要測試username
和score
如預期,但在收到什麼時候該消息並不關心。
目前我想寫點東西像這樣:
testProbe.expectMsgPF() {
case UserInfo(`username`, `score`, _) =>
}
怎麼能測試探針類進行擴展,使這樣的事情可能不是寫的?
testProbe.expectApproxMsg(UserInfo(`username`, `score`, _))
除了縮短我的代碼,我希望這個問題的答案會進一步我對Scala編程語言的理解。