2
私は自分の俳優の単体テストを書こうとしており、基本的な嘲笑に固執しています。 PriceAggregateActorはakkaの永続性を使用しています。私はそれをすべてのconfに渡したくないので、完全にそれを嘲笑したいと思います。私はいつもそうだAkkaで子どもの俳優を嘲笑
class CommandPriceActorTest extends TestKit(ActorSystem("test-benefits",
ConfigFactory.parseString("""akka.loggers = ["akka.testkit.TestEventListener"] """))) with FlatSpecLike with Matchers
with BeforeAndAfterAll with Eventually{
class MockedChild extends Actor {
def receive = {
case _ => lala
}
}
val probe = TestProbe()
val commandPriceActor = TestActorRef(new CommandPriceActor(Props[MockedChild]))
:
Caused by: java.lang.IllegalArgumentException: no matching constructor found on class CommandPriceActorTest$MockedChild for arguments []
この
は、私は私のような何かをしようとしている私のテストではそうobject CommandPriceActor {
def apply() = Props(classOf[CommandPriceActor], PriceAggregateActor())
}
class CommandPriceActor(priceAggregateActorProps: Props) extends Actor with ActorLogging {
val priceAggregateActor = context.actorOf(priceAggregateActorProps, "priceAggregateActor")
をテストしたい俳優であります
なぜmockedChildに不満がありますか?コンストラクタの引数を取るべきではありません。
私はあなたが言っているものを手に入れるが、私は、コードにすることをどのように書くのですか? :) – Reeebuuk
私はいくつかの例を追加しました。元の答えは私の電話の空港で行われました。 – iain
魅力的な作品です! Thxイアン:) – Reeebuuk