我想在每个测试文件的开头手动运行我的进化脚本。我正在与 Play 合作!2.4 和光滑 3。
根据文档,要走的路似乎是:
Evolutions.applyEvolutions(database)
但我无法获得我的数据库实例。在文档 play.api.db.Databases
中导入以获取数据库实例,但如果我尝试导入它,我会收到此错误:object Databases is not a member of package play.api.db
如何获取我的数据库实例以运行进化脚本?
编辑:如评论中所问,这是给出错误的整个源代码:
import models._
import org.scalatest.concurrent.ScalaFutures._
import org.scalatest.time.{Seconds, Span}
import org.scalatestplus.play._
import play.api.db.evolutions.Evolutions
import play.api.db.Databases
class TestAddressModel extends PlaySpec with OneAppPerSuite {
lazy val appBuilder = new GuiceApplicationBuilder()
lazy val injector = appBuilder.injector()
lazy val dbConfProvider = injector.instanceOf[DatabaseConfigProvider]
def beforeAll() = {
//val database: Database = ???
//Evolutions.applyEvolutions(database)
}
"test" must {
"test" in { }
}
}