ctierney
11/28/2018, 8:24 PMwithTestApplication
block is at a higher level. It would be nice to be able to create the TestEngine once (e.g. at the given("an application")
level) and use it in multiple on
/ it
contexts.orangy
withTestApplication
function and integrate it with Spek lifecyclesdave08
11/29/2018, 2:58 AMval application by memoized { withTestApplication... }
I guess.dave08
11/29/2018, 3:01 AMdave08
11/29/2018, 3:04 AMwithTestApplication
lambda... I don't think there's such a function outside of it, but I could be wrong.ctierney
11/29/2018, 8:17 PMkotlin
object AppSpec : Spek({
given("an application") {
val engine = TestApplicationEngine(createTestEnvironment())
beforeGroup {
engine.start()
engine.application.mainModule()
}
afterGroup {
engine.stop(0L, 0L, TimeUnit.MILLISECONDS)
}
with(engine) {
on("/v1/ping") {
it("should return pong") {
with(handleRequest(HttpMethod.Get, "/v1/ping")) {
assertEquals("pong", response.content)
}
}
}
on("/v2/ping") {
it("should return pong") {
with(handleRequest(HttpMethod.Get, "/v2/ping")) {
assertEquals("pong", response.content)
}
}
}
}
}
})
ctierney
11/29/2018, 8:17 PMorangy
ctierney
11/29/2018, 8:26 PM