Sorry, I did not find a solution, but only a workaround. He is using a forged object Globalfor testing, where the methods onStart()and onStop()empty.
First you need to split the object Globalinto an object and an empty object:
Global.scala
object Global extends Global
trait Global extends GlobalSettings { ... }
Global:
Fake.scala
object FakeGlobal extends Global {
override def onStart(app: Application): Unit = {}
override def onStop(app: Application): Unit = {}
}
object Fake {
def application() = FakeApplication(withGlobal = Some(FakeGlobal))
}
, , :
TasksRepositorySpec.scala
def insertTestData() = {
running(Fake.application()) {
//some code
}
}
. , !