我有一个非常简单的应用程序Jooby
用作 Web 框架。它负责 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
}
}