How to mock context(ActorContext)?
337 观看
1回复
2101 作者的声誉
I am using TestKit
to test the Akka Actors. I have a class Demo which has method getActorRef, which takes input as string and returns an ActorRef.
class Demo @Inject()(a: A. b: B, context: ActorContext) {
def getActorRef(id: String): ActorRef
}
I have mocked A,B while creating object of Demo.Now i am facing issue how to mock context.
What i did to mock it ? val context = mock[ActorContext]
But it didn't work.
作者: Mahesh Chand 的来源 发布者: 2017 年 12 月 27 日回应 1
0像
10 作者的声誉
It's not clear exactly what you're trying to do, or what errors you're encountering. I'm guessing you're using the ActorContext
to get an ActorRef
inside getActorRef
. If so, have you tried using Mockito to create a mock ActorContext
, passing that into Demo
when you construct it in the test, then stubbing out the ActorContext
method called by getActorRef
so that it returns the value you want (i.e., a ref to a test probe, or some such thing)?
I'd expect that to work, assuming that's what you're trying to do.
作者: yashap 发布者: 2017 年 12 月 29 日来自类别的问题 :
- scala 使用软件事务内存的任何真实体验?
- scala 将Java集合转换为Scala集合
- scala What does a single apostrophe mean in Scala?
- scala 适用于高性能Flash / Flex / AIR应用程序的大多数可扩展Web堆栈?
- unit-testing TDD和BDD之间的主要区别是什么?
- unit-testing 如何测试私有函数或具有私有方法,字段或内部类的类?
- unit-testing Python单元测试在哪里?
- unit-testing 如何模拟内存分配错误
- testing 用户界面测试
- testing 如何测试WPF用户界面?
- testing 用于使用webServices的Curl命令行?
- testing 确定bash中是否存在函数
- mocking 假装,嘲弄和捣蛋有什么区别?
- mocking 您如何在C#中模拟文件系统以进行单元测试?
- mocking 使用mockito验证对象属性值
- mocking 是否可以创建一个使用EasyMock实现多个接口的模拟对象?
- akka Akka - 对象序列化期间的StackOverflowError
- akka Akka Logging外面的演员
- akka 使用Java将PoisonPill发送给Actor
- akka 基于编号的线程配置。CPU核数