Skip to main content
Kotlin Multiplatform has no common API to read files from a test resources folder. FileKit.projectDir points to your module’s directory while tests run, so you can build paths to fixtures from shared test code.

Usage

Put the fixtures in a folder of your module, for example src/commonTest/resources/hello.txt, then read them:
jvmTest
projectDir is declared in nonWebMain, so it doesn’t compile in commonTest when your module has JS or Wasm targets. Put the test in a test source set without web targets, such as jvmTest, iosTest, or a shared nonWebTest you declare. The fixtures folder can stay anywhere in the module.

How each platform finds the module

projectDir is for tests and tooling only. Don’t use it in production code.