I'm trying to write unit tests for my actor and am stuck on basic mocking. PriceAggregateActor is using akka persistence and I don't want to pass in all the conf for it and would like to mock it completely.
This is the actor that I want to test
object CommandPriceActor {
def apply() = Props(classOf[CommandPriceActor], PriceAggregateActor())
}
class CommandPriceActor(priceAggregateActorProps: Props) extends Actor with ActorLogging {
val priceAggregateActor = context.actorOf(priceAggregateActorProps, "priceAggregateActor")
So in my tests I'm trying to do something like:
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]))
I'm always getting:
Caused by: java.lang.IllegalArgumentException: no matching constructor found on class CommandPriceActorTest$MockedChild for arguments []
Why is it complaining about mockedChild? It shouldn't take any constructor arguments.
Aucun commentaire:
Enregistrer un commentaire