I am trying to set up integration tests to prepare our database. I am using sbt 1.0.3 and Scala 2.11.11 in Play 2.6.12.
I added this section in build.sbt:
lazy val fnHelper = taskKey[Unit]("FnTest Helpers")
testOptions in IntegrationTest += Tests.Setup(
() => {
println("########################### Prepare Functional Tests #####################")
fullRunTask(fnHelper, IntegrationTest, "helper.FTTestHelper")
println("#################################### Finished ")
});
testOptions in IntegrationTest += Tests.Cleanup( () => println("clean up") )
Below is the task class,
object FTTestHelper {
val logger: Logger = Logger(this.getClass())
def setUpDatabase(): Unit = {
println("################################Setup metadata database###########################")
val process = Runtime.getRuntime.exec("main/functionalTest/updateFnDatabaseMetadata.sh")
if ( process.exitValue() != 0) {
throw new RuntimeException("fail to update metadata")
}
}
def main(args: Array[String]):Unit = {
println("############execute FT TestHelper #############")
setUpDatabase()
}
}
When I ran "sbt it:test", console shows:
[warn] javaOptions will be ignored, fork is set to false
########################### Prepare Functional Tests #####################
#################################### Finished
But the FTTestHelper was not executed, even I moved the "fullRunTask(fnHelper, IntegrationTest, "helper.FTTestHelper")" out of Tests.Setup. Did I miss anything here? Thanks