我试图弄清楚如何使用 specs2 在 Play 框架中测试多个 URL,但如果不启动多个服务器,我似乎无法找出正确的方法。
import org.specs2.mutable._
import play.api.test._
import play.api.test.Helpers._
import play.api.libs.ws.WS
class testServer extends Specification {
running(TestServer(9000)) {
"Server starts" in {
await(WS.url("http://localhost:9000").get).status must equalTo(OK)
}
"Who" in {
await(WS.url("http://localhost:9000/url1").get).status must equalTo(OK)
}
"How" in {
await(WS.url("http://localhost:9000/url2").get).status must equalTo(OK)
}
"Why" in {
await(WS.url("http://localhost:9000/url3").get).status must equalTo(OK)
}
"Test4" in {
await(WS.url("http://localhost:9000/url4").get).status must equalTo(OK)
}
"Test" in {
await(WS.url("http://localhost:9000/url5").get).status must equalTo(OK)
}
"Help" in {
await(WS.url("http://localhost:9000/url6").get).status must equalTo(OK)
}
"Bogus" in {
await(WS.url("http://localhost:9000/url7").get).status must equalTo(OK)
}
}
}