简体   繁体   中英

Scala play Unit test controller 2.6.x - object Execution in package concurrent is deprecated: Please see 2.6 migration guide

Trying to follow the migration guide from Scala play framework version 2.6 as from: https://playframework.com/documentation/2.6.x/Highlights26

and after upgrading my tests are breaking:

val controller = new ProductController(stubControllerComponents().asInstanceOf[ProductControllerComponents])

I get:

> object Execution in package concurrent is deprecated: Please see
> https://www.playframework.com/documentation/2.6.x/Migration26#Execution

This is my controller declaration:

class ProductController @Inject()(cc: ProductControllerComponents)(implicit ec: ExecutionContext)
    extends ProductBaseController(cc)

and my injected execution context is "executionContext: scala.concurrent.ExecutionContext"

I'm following the official play framework 2.6 examples, but still test is not compiling throwing the error msg above.

See playframework/framework/src/play/src/main/scala/play/api/mvc/Controller.scala

  /**
   * The default execution context provided by Play. You should use this for non-blocking code only. You can do so by
   * passing it explicitly, or by defining an implicit in your controller like so:
   *
   * {{{
   *   implicit lazy val executionContext = defaultExecutionContext
   * }}}
   */
  def defaultExecutionContext: ExecutionContext = controllerComponents.executionContext

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM