https://kotlinlang.org logo
p

Peter Mandeljc

07/29/2021, 7:14 PM
Hey guys, I'm considering using ktor for rest client, instead of Retrofit. Do you mind sharing any opinions on that topic? I'm also interested in unit testing.
m

Marko Novakovic

07/29/2021, 7:18 PM
I use it in my projects. I like it. Depends on what you prefer. Nothing wrong with either one
c

Colton Idle

07/29/2021, 7:28 PM
I guess it's nice that ktor is KMM compatible.
c

CLOVIS

07/29/2021, 8:02 PM
I think the only bad part is that Ktor isn't very well documented. It's a really nice tool though.
p

Peter Mandeljc

07/29/2021, 8:10 PM
It shouldn't be that bad, if you're still using it I guess 🙂
Did you try to unit test ktor? Judging from documentation, testing seems a bit more practical to me maybe
j

Jeremy

07/29/2021, 10:18 PM
They're both wrappers on top of OkHttp
They're both testable and support similar features. ktor supports MPP and has nicer api imo. I use ktor in new projects. For simple stuff I just use okhttp directly
I haven't had any issues w/ the ktor client documentation. Its pretty simple
c

CLOVIS

07/30/2021, 8:00 AM
Yep I'm using basic unit tests (as shown in the docs). It's easy to use and works well, but I haven't used unit tests in other frameworks so I can't compare it to anything.
j

Jeremy

07/30/2021, 8:52 PM
retrofit just exposes api as an interface so you just make a fake or mock
x

xxfast

07/31/2021, 1:59 AM
ktor doesn’t only just wrap okhttp - there are multiple engines that ktor ‘wraps’ around