Hello! Did anyone implemented unit-tests with real endpoints and with out mocks in KMM?
t
Tijl
01/18/2022, 7:38 PM
yes, any specific question?
e
Evgenii Sokol
01/19/2022, 8:27 AM
I have few question about testing real endpoint in shared part. 1. How you get expected object? 2. Did you use Koin or some DI for shared part?
t
Tijl
01/19/2022, 8:29 AM
so is your question how to use real endpoints in tests, or how to avoid using real endpoints, but without using a mocking library?
e
Evgenii Sokol
01/19/2022, 9:08 AM
First one. In my case test have to auth user using real endpoint. Also login mechanic have platform specific injection (expect\actual).
t
Tijl
01/19/2022, 9:10 AM
I do something similar though I auth with a token, which I include in the build through
BuildKonfig
(which gets it from a property or env variable).
🙌 1
Tijl
01/19/2022, 9:13 AM
in my case the auth stuff is all handled by the implementation (which is expect/actual but all wrapped up in a library), but if you need to do platform specific stuff for the test, one thing I often do is make an abstract test class with all the tests in it, that I then extend for each specific platform that supports these kinds of test, and they do their platform specific stuff as needed.
It’s also possible to just use expect/actual in a test class for that though.