【发布时间】:2019-01-22 09:42:07
【问题描述】:
我有一个非常简单的应用程序,它使用Jooby 作为网络框架。它负责 REST 的类看起来像这样
class Sandbox : Kooby ({
path("/sandbox") {
get {
val environment = require(Config::class).getString("application.env")
"Current environment: $environment"
}
get ("/:name") {
val name = param("name")
"Auto response $name"
}
}
})
我想为它编写集成测试。我的测试看起来像这样。我使用spock 和rest-assured。问题是我没有运行应用程序,而是想使用某种嵌入式服务器或其他方式运行它。该怎么做?
我的简单测试是这样的
class SandboxTest extends Specification {
def "check current environment"() {
given:
def request = given()
when:
def response = request.when().get("/sandbox")
then:
response.then().statusCode(200) // for now 404
}
}
【问题讨论】: