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

Hi there,

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

FileBasedIndex.getInstance().requestRebuild(INDEX_NAME)

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

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