# To runWriteActionAndWait or not and path confusion

**URL:** https://platform.jetbrains.com/t/to-runwriteactionandwait-or-not-and-path-confusion/3140
**Category:** IntelliJ Platform
**Tags:** plugin-development
**Created:** [November 17, 2025, 8:26am UTC](https://platform.jetbrains.com/t/to-runwriteactionandwait-or-not-and-path-confusion/3140 "2025-11-17T08:26:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![martin.hauner](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/martin.hauner/32/291_2.png) [@martin.hauner](https://platform.jetbrains.com/u/martin.hauner)
#### Post date: [November 17, 2025, 8:26am UTC](https://platform.jetbrains.com/t/to-runwriteactionandwait-or-not-and-path-confusion/3140/1 "2025-11-17T08:26:28Z")

</div>

I’m trying to rewrite a gutter test.

It copies files to the project. Running it it complains that I should use `runWriteActionAndWait`. I added it and it no longer complains.

```auto
// LightInsightTestCase = LightJavaCodeInsightFixtureTestCase5
class MappingAnnotationLineMarkerSpec: LightInsightTestCase() {

    override fun getTestDataPath(): String {
        return "src/test/testdata/interface-to-openapi/paths"
    }

    @Test
    fun `adds navigation gutter icon to mapping annotation`() {
        runWriteActionAndWait {
            fixture.copyDirectoryToProject("", "")
        }

        val gutters = fixture.findAllGutters("api/Api.java")
        assertEquals(2, gutters.size)
    }
}

```

What I do not understand is that existing tests (of IntelliJ) copy without `runWriteActionAndWait`. For example: [DescriptionTypeRelatedItemLineMarkerProviderTest](https://github.com/JetBrains/intellij-community/blob/57829b5dbd3247ad575ec27e540d3e592ba9dda8/plugins/devkit/devkit-java-tests/testSrc/org/jetbrains/idea/devkit/navigation/DescriptionTypeRelatedItemLineMarkerProviderTest.java#L37)

Another issue I do not understand is that the file I check has a virtual file: `temp:///src/api/Api.java` but the `project.basePath` is somethink like `/private/var/folders/8w/jcbd06095qxb0379t1rs9rfr0000gn/T/unitTest__35b5RtmSinu7SwZUBxg5EKvKSKt`.

My gutter calculation walks the project/modules/source roots and it expects the `src/api/Api.java` below the `project.basePath`.

This works if I use the plugin but fails in the test.

Why don’t file and project base path match?

---

<div class="post-metadata">

### Author: ![jansorg](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/jansorg/32/52_2.png) [@jansorg](https://platform.jetbrains.com/u/jansorg)
#### Post date: [November 17, 2025, 9:26am UTC](https://platform.jetbrains.com/t/to-runwriteactionandwait-or-not-and-path-confusion/3140/2 "2025-11-17T09:26:38Z")

</div>

These tests are using different base classes and initialize the temp dir fixture differently.

If you check the sources, you’ll see that `DescriptionTypeRelatedItemLineMarkerProviderTest` creates a `TempDirTestFixtureImpl` under the hood. The frankenstein `LightJavaCodeInsightFixtureTestCase5` creates a `LightTempDirTestFixtureImpl`.

The former creates temp files on disk, the latter (yours) creates temp files in memory.

The project directory is based on disk for both tests.

If I’m not mistaken, you could only add a execution policy to change the temp dir fixture implementation: [intellij-community/java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java at 222c7b2612a2241218ac7eaf0ec94048fc123d42 · JetBrains/intellij-community · GitHub](https://github.com/JetBrains/intellij-community/blob/222c7b2612a2241218ac7eaf0ec94048fc123d42/java/testFramework/src/com/intellij/testFramework/fixtures/LightJavaCodeInsightFixtureTestCase.java#L133)

But I recommend to switch to the new way of JUnit5 tess, not the compatibility mode class which only provides limited functionality or configurability.

I can’t tell why you need a write action. The stacktrace is missing, most likely you’re not executing tests on the EDT or something else is different.

---

<div class="post-metadata">

### Author: ![martin.hauner](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/martin.hauner/32/291_2.png) [@martin.hauner](https://platform.jetbrains.com/u/martin.hauner)
#### Post date: [November 18, 2025, 8:22am UTC](https://platform.jetbrains.com/t/to-runwriteactionandwait-or-not-and-path-confusion/3140/3 "2025-11-18T08:22:40Z")

</div>

Thanks. That disk vs memory is a useful piece of information 🙂

Using the “new” way was my plan. So let me try that again 🙂
