I am writing Specs2 tests for methods returning futures in a project using Scala and Play framework. Documentation and answers to this question recommend using the await modifier, which requires to add implicit ExecutionEnv. A minimal working example (adapted from one of the mentioned answers):
class FutureSpec extends mutable.Specification {
"Even in future one" should {
"be greater than zero" in { implicit ee: ExecutionEnv =>
Future(1) must be_>(0).await
}
}
}
But some of my tests require WithApplicationLoader. If I add it to the example, it does not compile:
class FutureSpec extends mutable.Specification {
"Even in future one" should {
"be greater than zero" in new WithApplicationLoader { implicit ee: ExecutionEnv =>
Future(1) must be_>(0).await
}
}
}
WithApplication instead of WithApplicationLoader has exactly the same effect (expectedly).
Is it possible to use WithApplicationLoader together with implicit ExecutionEnv?
Unfortunately, the second option described in the documentation -- moving ExecutionEnv to the class constructor instead of a particular method -- is not available. This specification:
class FutureSpec(implicit ee: ExecutionEnv) extends mutable.Specification {
"Even in future one" should {
"be greater than zero" in new WithApplicationLoader {
Future(1) must be_>(0).await
}
}
}
works, but it is ignored by IntelliJ Idea (I can run such a specification separately, but the configuration running all tests in the project does not execute it).