2
我测试代码哪些流通过获得一个多输出流的TCP连接的消息:测试阿卡反应流
(IO(StreamTcp) ? StreamTcp.Connect(settings, address))
.mapTo[StreamTcp.OutgoingTcpConnection]
.map(_.outputStream)
在测试中,我与虚拟用户替换所得Subscriber[ByteString]
,引发一些传出消息,并声称已按预期到达。我使用下面的方法来产生虚拟用户和流结果未来。 (到目前为止,一切都很好)
def testSubscriber[T](settings: FlowMaterializer)(implicit ec: ExecutionContext): (Subscriber[T], Future[Seq[T]]) = {
var sent = Seq.empty[T]
val (subscriber, streamComplete) =
Duct[T].foreach(bs => sent = sent :+ bs)(settings)
(subscriber, streamComplete.map(_ => sent))
}
我的问题是:是否有用于测试流输出的预期值,类似于阿卡的TestActorRef
一些东西规范的方法?如果没有,是否有一些库功能类似于上述功能?