播放:在测试中通过 URL 访问静态文件
Play: Accessing static files via URL in tests
我在 public 文件夹中有一个静态 xml 文件,我想通过触发
来访问它
WS.url(myFileUrl)
来自我的测试。任何的想法?
问题是,如果您想通过 URL 访问静态文件,您需要有一个真正的服务器 运行 并为请求提供服务。所以你可以添加服务器并指定端口如下:
"run in a server" in new WithServer(port = 3333)) {
await(WS.url("http://localhost:3333").get).status must equalTo(OK)
}
我在 public 文件夹中有一个静态 xml 文件,我想通过触发
来访问它WS.url(myFileUrl)
来自我的测试。任何的想法?
问题是,如果您想通过 URL 访问静态文件,您需要有一个真正的服务器 运行 并为请求提供服务。所以你可以添加服务器并指定端口如下:
"run in a server" in new WithServer(port = 3333)) {
await(WS.url("http://localhost:3333").get).status must equalTo(OK)
}