my way of testing futures was using value1. I migrated to play2.2. I found out, my accustomed way to test is gone. @scala.deprecated("Use scala.concurrent.Promise instead.", "2.2")
Any help would be greatly appreciated.
Oliver
You can implement the PlaySpecification trait as described in the documentation. This trait provides a method await. You can also override the default timeout.
import akka.util.Timeout
import scala.concurrent.duration._
class FooSpec extends PlaySpecification {
override implicit def defaultAwaitTimeout: Timeout = 20.seconds
"foo" should {
"handle futures" {
val result = await(Future(true))
result should beTrue
}
}
}
You can also override the default timeout for a single test scenario, like so:
import akka.util.Timeout
import scala.concurrent.duration._
class FooSpec {
"foo" should {
"handle futures" with DefaultAwaitTimeout {
override implicit def defaultAwaitTimeout: Timeout = 20.seconds
val result = await(Future(true))
result should beTrue
}
}
}
To stop your code at a specific position, use
Thread.sleep(milliseconds)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With