https://kotlinlang.org logo
#ktor
Title
# ktor
m

Marc Knaup

02/11/2021, 5:14 PM
Is there a way to connect client & server test engines? So that a Ktor client with test engine executes its request on a Ktor server with test engine.
e

e5l

02/11/2021, 6:14 PM
Yep, there is
TestApplicationEngine
and it works with client as well
m

Marc Knaup

02/11/2021, 6:26 PM
How do I connect the two? So that
HttpClient
uses the
TestApplicationEngine
to run requests in the server pipeline.
e

e5l

02/11/2021, 7:22 PM
TestApplicationEngine
class has
client
field
so when you use this client instance, engine will get all requests
withApplication
creates test server with test engine, and the
client
is used in 54 line to make the request
All requires stuff is available in
ktor-server-test-host
module
m

Marc Knaup

02/11/2021, 7:27 PM
Ah,
TestHttpClientEngine
. I need an engine factory. That will do, thank you 🙏
2 Views