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.
o
orangy
11/28/2018, 8:42 PM
I don’t think it is about reusing. It looks like Spek and Ktor DSLs intersect in some way and test engine is stopped too early. May be you need to unroll
withTestApplication
function and integrate it with Spek lifecycles
d
dave08
11/29/2018, 2:58 AM
You could use
val application by memoized { withTestApplication... }
I guess.
dave08
11/29/2018, 3:01 AM
The test discovery stage runs all the code outside the `it`s and then runs them in the actual testing mode, so in cause a few funny situations... memoized recreates the instance before the actual teat according to what you provide in it's parameter.
dave08
11/29/2018, 3:04 AM
The thing is that the `handeRequest`s might need to be inside the
withTestApplication
lambda... I don't think there's such a function outside of it, but I could be wrong.
The first test takes 100--200ms, following tests take 5--10ms---so there’s definitely a benefit to doing it this way (as opposed to starting a new TestApplicationEngine for every test)
o
orangy
11/29/2018, 8:18 PM
Yep, but honestly even 100ms for a complete web test environment is not bad at all 😉