# How to wait for indexing to be finished in a test?

**URL:** https://platform.jetbrains.com/t/how-to-wait-for-indexing-to-be-finished-in-a-test/3789
**Category:** IntelliJ Platform
**Created:** [March 1, 2026, 5:16pm UTC](https://platform.jetbrains.com/t/how-to-wait-for-indexing-to-be-finished-in-a-test/3789 "2026-03-01T17:16:09Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kolchinmax](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/kolchinmax/32/374_2.png) [@kolchinmax](https://platform.jetbrains.com/u/kolchinmax)
#### Post date: [March 1, 2026, 5:16pm UTC](https://platform.jetbrains.com/t/how-to-wait-for-indexing-to-be-finished-in-a-test/3789/1 "2026-03-01T17:16:10Z")

</div>

Hi there,

I have the following line in my plugin’s code:

```kotlin
FileBasedIndex.getInstance().requestRebuild(INDEX_NAME)

```

and in my `BasePlatformTestCase` test I have the following implementation of the `setUp()` method:

```auto
override fun setUp() {
    super.setUp()

    service<ServiceThatUsesFileBasedIndex>().doRebuildIndex()

    PlatformTestUtil.dispatchAllEventsInIdeEventQueue()
    PlatformTestUtil.waitForAllBackgroundActivityToCalmDown()
    IndexingTestUtil.waitUntilIndexesAreReadyInAllOpenedProjects()
}

```

Still a test is not able to fetch expected values from the index. What am I missing here?

Environment:

- Junit: 4
- Intellij Platform SDK: 261-EAP-SNAPSHOT

Regards,  
Maksim
