我正在尝试使用MockitoSugar在scala中为我的私有方法编写单元测试用例,但它正在抛出无法找到私有方法异常。这是我的代码。
object ActivityRepo{
private def addActivity(activity:Activity):Future[Activity]={
//doing DB calls
}
}
单元测试:
"Activity Repo Test" must {
"add Activity" in {
// doing mock for the DB calls
val addActivity = PrivateMethod[Future[Activity]]('addActivity)
val result = ActivityRepo invokePrivate addActivity (activity)
// doing assertions
}
}
错误在哪里?