> ## Documentation Index
> Fetch the complete documentation index at: https://filekit.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Test resources

> Read test fixture files from shared Kotlin Multiplatform tests with FileKit.projectDir

[See the platform support matrix](https://filekit.mintlify.site/platform-support.md#filekit-core)

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:

```kotlin jvmTest theme={null}
import io.github.vinceglb.filekit.FileKit
import io.github.vinceglb.filekit.div
import io.github.vinceglb.filekit.exists
import io.github.vinceglb.filekit.projectDir
import io.github.vinceglb.filekit.readString
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue

class ResourcesTest {
    private val resources = FileKit.projectDir / "src/commonTest/resources"

    @Test
    fun readHello() = runTest {
        val hello = resources / "hello.txt"
        assertTrue(hello.exists())
        assertEquals("Hello, World!", hello.readString())
    }
}
```

`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

| Platform | `projectDir` | Works in |
| - | - | - |
| JVM, macOS, Linux native, Windows native | `PlatformFile(".")`, the working directory | Gradle test tasks, which run from the module directory |
| Android | `PlatformFile(".")` | Local unit tests that run on your computer. On a device or emulator, `.` is not your project. |
| iOS, watchOS | Four folders above the test bundle | Simulator tests, where that is the module directory. Not on a real device. |

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

## Related

* [App directories](https://filekit.mintlify.site/core/file-utils.md) for runtime locations.
* [Reading files](https://filekit.mintlify.site/core/read-file.md) for the full read API.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.