//DataBaseAdapterObject.scala
package services.db
object DataBaseAdapterObject{
def findAllBlogItems() : List[String] = {
........
........
List("One", "Two", "Three")
}
}
//BaseService.scala
package services
import services.db._
object BaseService {
implicit val db = DataBaseAdapterObject;
}
//BlogItemService.scala
package services
import services.BaseService._
object BlogItemService {
def findAll() : List[String] = {
db.findAllBlogItems()
}
}
For above implementation I want to write unit test for the BlogItemService.findAll, The problem is because the db val is resolved by import I cannot mock the db object.
Does anybody know how to mock that implicit import db.
The code can be written differently by implementing DI but I want to know if any work around for this case?