Search code examples
scalaakka-testkit

Setting the time wait period for Get() in akka-http testkit?


I am using the akka-http test suite. I have the following code, where the test "fails" whenever I delay the server response by more than 1 second.

"should give default" in {
    Get("/test/") ~> route ~> check {
      responseAs[Array[Byte]] shouldEqual defaultImage
    } 
  }

The error message is:

Request was neither completed nor rejected within 1 second

Is it possible to modify this waiting time, for instance with an implicit?


Solution

  • You can provide your own RouteTestTimeout implicit to override the timeout, the default definition is:

    implicit def default(implicit system: ActorSystem) = RouteTestTimeout(1.second dilated)
    

    Source