Hello! Did anyone implemented unit-tests with real...
# multiplatform
e
Hello! Did anyone implemented unit-tests with real endpoints and with out mocks in KMM?
t
yes, any specific question?
e
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
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
First one. In my case test have to auth user using real endpoint. Also login mechanic have platform specific injection (expect\actual).
t
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
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.
🙌 1