【问题标题】:Where is the port defined in the default IntegrationSpec in the scala play framework?scala play框架中默认IntegrationSpec中定义的端口在哪里?
【发布时间】:2017-02-09 13:15:48
【问题描述】:

scala play 框架的默认集成规范如下:

class IntegrationSpec extends PlaySpec with OneServerPerTest with OneBrowserPerTest with HtmlUnitFactory {

  "Application" should {

    "work from within a browser" in {

      go to ("http://localhost:" + port)

      pageSource must include ("Your new application is ready.")
    }
  }
}

单击port 变量打开OneServerPerTest.scala 文件:

  /**
   * The port used by the `TestServer`.  By default this will be set to the result returned from
   * `Helpers.testServerPort`. You can override this to provide a different port number.
   */
  lazy val port: Int = Helpers.testServerPort

单击Helpers.testServerPort 会导致:

  /**
   * The port to use for a test server. Defaults to 19001. May be configured using the system property
   * testserver.port
   */
  lazy val testServerPort = Option(System.getProperty("testserver.port")).map(_.toInt).getOrElse(19001)

搜索testserver.port 不会返回变量。当默认端口是 9000 并且 testserver.port 定义在哪里时,测试怎么可能成功?

【问题讨论】:

    标签: scala playframework


    【解决方案1】:

    TestServer 使用此端口启动,如you can see here。端口 9000 是开发模式的默认端口,并非所有测试模式。如果您没有在用于启动测试的命令中设置 testserver.port 属性,则将使用默认值 (19001)。

    【讨论】:

      猜你喜欢
      • 2015-06-19
      • 1970-01-01
      • 1970-01-01
      • 2018-12-16
      • 2014-11-20
      • 1970-01-01
      • 2016-08-03
      • 1970-01-01
      • 2020-09-30
      相关资源
      最近更新 更多