We have a test fixtures module, and in there we ar...
# multiplatform
j
We have a test fixtures module, and in there we are using some large json files to build up said fixtures, that we can then use for unit testing in other modules. composeResources seems to work only when running on the iOS target. I am guessing composeResources are not ideal for this usecase, if so, is there a recommended way to load files to later use in commonTest?
o
In preparation for a possible addition to the #C09FQGG85EC test framework, I'd like to understand your use case: 1. If you had the option of supplying the contents of arbitrary files in your sources to any test target in the same module, would that help? (Also note that some targets, e.g. browsers, don't have a file system, so you couldn't store such contents there in the usual way.) 2. Which targets would you use?
j
Our use case is a mobile app with two targets, iOS and Android. I'm not sure it matters much to run the unit tests both on Android, and on the ios simulator target, but I think that happens with ./`gradlew check.` We ended up loading the file from common main/resources. This works for the Android tests, and then we provided an absolute path for the iOS simulator to load the file. It's ugly, but works.
o
Thanks! Good to hear that it worked for you.
v
@joakim a bit off topic - could you share how you setup test fixtures in KMP? Is there some alternative to
java-test-fixtures
for KMP? Do you set-up your own custom test fixtures in Gradle? Something else?
j
these are just our own custom test fixtures
o
@Vito Medved For a KMP
java-test-fixtures
equivalent, what if you’d create a
test-fixtures
Gradle module with your test fixtures sources in
commonMain
, then add
test-fixtures
dependencies in
commonTest
of your consuming modules?
j
That's pretty much what we have
v
That would work, thanks!
👍 1