Hey is there any convenient way to load fixtures/r...
# multiplatform
m
Hey is there any convenient way to load fixtures/resources in common tests without turning those resources into strings? For example JSON files become very ugly to deal with. Any pointers?
b
Expect/actual or okio to read files in common sourceSet
m
You mean to implement the Reader by myself?...well I hoped for a more non-custom implementation... Thx you anyways!
b
No, not implement it, just use expect/actual to hook in native file APIs for each platform. Or alternatively check out okio lib to see if it's sufficient for you.
m
Thx!
a
I was about to do the same but found out about """ strings. For JSON if you use the """ syntax for strings - no need to escape it and everything stays in one place - no extra files, readers, etc - just copy and paste from actual api call.
m
Well...I made my way around...I simply implemented it without the Helpers for JVM/Android...so I have a reliable way to use it in iOS...and keep it open for JS
b
To follow up with @Alexander Atanasov idea, I've remembered that I have this gist to easily convert any textual file to kotlin const val. Hook it up to some gradle task and you can generate sources for those on the fly, while maintaining the convenience of keeping resources in json format https://gist.github.com/mpetuska/a3167f5848ea9b6f657a06d0e2c1bc72