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.
// 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
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?