class MyTestCase : LightPlatformCodeInsightFixture4TestCase() {
@Test
fun testFoo() {
myFixture.configureByFile("some-file.ext")
project.guessProjectDir() // `temp:///src`
myFixture.file.virtualFile.toNioPath() // UnsupportedOperationException
}
}
I’m interacting with an external tool, so I need the files to be physically written to disk. How do I make the fixture do that? I tried overriding createMyFixture() and createTempDirTestFixture(), but that didn’t work (in both cases, NoSuchFileException was raised during calls to TempDirTestFixtureImpl.getFile()):
final override fun createMyFixture(): CodeInsightTestFixture? {
val fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory()
val name = """${this::class.java.name}.$name"""
val projectBuilder = fixtureFactory.createFixtureBuilder(name)
return fixtureFactory.createCodeInsightFixture(projectBuilder.fixture)
}
internal class LanguageServerTest : LightPlatformCodeInsightFixture4TestCase() {
override fun setUp() {
super.setUp()
myFixture.testDataPath = "src/test/testData/..."
}
override fun createTempDirTestFixture() = TempDirTestFixtureImpl()
@Test
fun `test diagnostics - python file`() {
myFixture.configureByFile("F401.py")
// assertSomething(...)
}
}
And here’s the log entry:
22:38:10,026 FINE impl.local.LocalFileSystemBase - /tmp/unitTest__diagnostics___python_file_30ChVwM4hKUcse25qVg8S2WvIUJ/unitTest18312545256062028071/F401.py
java.nio.file.NoSuchFileException: /tmp/unitTest__diagnostics___python_file_30ChVwM4hKUcse25qVg8S2WvIUJ/unitTest18312545256062028071/F401.py
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:171)
at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
at java.base/java.nio.file.Files.readAttributes(Files.java:1854)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl.readAttributes(LocalFileSystemImpl.java:369)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl.lambda$new$2(LocalFileSystemImpl.java:53)
at com.intellij.openapi.vfs.DiskQueryRelay.lambda$new$0(DiskQueryRelay.java:56)
at com.intellij.openapi.vfs.DiskQueryRelay.accessDiskWithCheckCanceled(DiskQueryRelay.java:71)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl.getAttributes(LocalFileSystemImpl.java:322)
at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.createAndFindChildWithEventFire(VirtualDirectoryImpl.java:337)
at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.findChild(VirtualDirectoryImpl.java:88)
at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.refreshAndFindChild(VirtualDirectoryImpl.java:387)
at com.intellij.openapi.vfs.newvfs.VfsImplUtil.refreshAndFindFileByPath(VfsImplUtil.java:118)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemBase.refreshAndFindFileByPath(LocalFileSystemBase.java:67)
at com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl.lambda$getFile$1(TempDirTestFixtureImpl.java:78)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteAction$lambda$15(AnyThreadWriteThreadingSupport.kt:623)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWithTemporaryThreadLocal(AnyThreadWriteThreadingSupport.kt:204)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteAction(AnyThreadWriteThreadingSupport.kt:623)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteAction(AnyThreadWriteThreadingSupport.kt:617)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:998)
at com.intellij.openapi.application.WriteAction.computeAndWait(WriteAction.java:133)
at com.intellij.openapi.application.WriteAction.computeAndWait(WriteAction.java:127)
at com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl.getFile(TempDirTestFixtureImpl.java:78)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.copyFileToProject(CodeInsightTestFixtureImpl.java:446)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.copyFileToProject(CodeInsightTestFixtureImpl.java:420)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.configureByFileInner(CodeInsightTestFixtureImpl.java:1593)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.configureByFilesInner(CodeInsightTestFixtureImpl.java:1493)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.configureByFile(CodeInsightTestFixtureImpl.java:1500)
at insyncwithfoo.ryecharm.ruff.lsp.LanguageServerTest.test diagnostics - python file(LanguageServerTest.kt:51)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at com.intellij.testFramework.TestLoggerKt$recordErrorsLoggedInTheCurrentThreadAndReportThemAsFailures$2.invoke(testLogger.kt:99)
at com.intellij.testFramework.TestLoggerKt$recordErrorsLoggedInTheCurrentThreadAndReportThemAsFailures$2.invoke(testLogger.kt:99)
at com.intellij.testFramework.TestLoggerKt.recordErrorsLoggedInTheCurrentThreadAndReportThemAsFailures(testLogger.kt:81)
at com.intellij.testFramework.TestLoggerKt.recordErrorsLoggedInTheCurrentThreadAndReportThemAsFailures(testLogger.kt:99)
at com.intellij.testFramework.UsefulTestCase.lambda$wrapTestRunnable$15(UsefulTestCase.java:533)
at com.intellij.testFramework.UsefulTestCase.runTestRunnable(UsefulTestCase.java:426)
at com.intellij.testFramework.fixtures.BasePlatformTestCase.runTestRunnable(BasePlatformTestCase.java:117)
at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:442)
at com.intellij.testFramework.UsefulTestCase.lambda$runBare$13(UsefulTestCase.java:515)
at com.intellij.testFramework.EdtTestUtil.lambda$runInEdtAndWait$5(EdtTestUtil.java:92)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:240)
at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:25)
at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:202)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runIntendedWriteActionOnCurrentThread$lambda$7(AnyThreadWriteThreadingSupport.kt:319)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction$lambda$6(AnyThreadWriteThreadingSupport.kt:274)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWithTemporaryThreadLocal(AnyThreadWriteThreadingSupport.kt:204)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:274)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:222)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runIntendedWriteActionOnCurrentThread(AnyThreadWriteThreadingSupport.kt:318)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:928)
at com.intellij.openapi.application.impl.ApplicationImpl$4.run(ApplicationImpl.java:501)
at com.intellij.openapi.application.impl.AppImplKt.rethrowExceptions$lambda$2(appImpl.kt:66)
at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:102)
at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:102)
at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:108)
at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:102)
at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
at com.intellij.openapi.application.impl.AppImplKt.rethrowExceptions$lambda$3(appImpl.kt:77)
at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:105)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:117)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:43)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:728)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:750)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:585)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:482)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$12$lambda$11$lambda$10$lambda$9(IdeEventQueue.kt:307)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:864)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$12$lambda$11$lambda$10(IdeEventQueue.kt:306)
at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$3(IdeEventQueue.kt:958)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:117)
at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:958)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$12(IdeEventQueue.kt:301)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:341)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
Override getTestDataPath instead of setting the property in setUp(). super.setUp() already initializes the fixture with the result from getTestDataPath()
Make the path returned by getTestDataPath() absolute
Unfortunately, that still doesn’t work. Updated code:
internal class LanguageServerTest : LightPlatformCodeInsightFixture4TestCase() {
override fun setUp() {
super.setUp()
}
override fun createTempDirTestFixture() = TempDirTestFixtureImpl()
// Ubuntu on GHA: `/home/runner/work/project/project/src/test/testData/...`
override fun getTestDataPath() = (Path.of("").toAbsolutePath() / "...").toString()
@Test
fun `test diagnostics - python file`() {
myFixture.configureByFile("F401.py")
// assertSomething(...)
}
}
Log entry:
09:05:35,299 FINE impl.local.LocalFileSystemBase - /tmp/unitTest__diagnostics___python_file_30Dvouza67w9DeaksqrTYVPf76H/unitTest10148443344264403660/F401.py
java.nio.file.NoSuchFileException: /tmp/unitTest__diagnostics___python_file_30Dvouza67w9DeaksqrTYVPf76H/unitTest10148443344264403660/F401.py
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:171)
at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
at java.base/java.nio.file.Files.readAttributes(Files.java:1854)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl.readAttributes(LocalFileSystemImpl.java:369)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl.lambda$new$2(LocalFileSystemImpl.java:53)
at com.intellij.openapi.vfs.DiskQueryRelay.lambda$new$0(DiskQueryRelay.java:56)
at com.intellij.openapi.vfs.DiskQueryRelay.accessDiskWithCheckCanceled(DiskQueryRelay.java:71)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl.getAttributes(LocalFileSystemImpl.java:322)
at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.createAndFindChildWithEventFire(VirtualDirectoryImpl.java:337)
at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.findChild(VirtualDirectoryImpl.java:88)
at com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.refreshAndFindChild(VirtualDirectoryImpl.java:387)
at com.intellij.openapi.vfs.newvfs.VfsImplUtil.refreshAndFindFileByPath(VfsImplUtil.java:118)
at com.intellij.openapi.vfs.impl.local.LocalFileSystemBase.refreshAndFindFileByPath(LocalFileSystemBase.java:67)
at com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl.lambda$getFile$1(TempDirTestFixtureImpl.java:78)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteAction$lambda$15(AnyThreadWriteThreadingSupport.kt:623)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWithTemporaryThreadLocal(AnyThreadWriteThreadingSupport.kt:204)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteAction(AnyThreadWriteThreadingSupport.kt:623)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteAction(AnyThreadWriteThreadingSupport.kt:617)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:998)
at com.intellij.openapi.application.WriteAction.computeAndWait(WriteAction.java:133)
at com.intellij.openapi.application.WriteAction.computeAndWait(WriteAction.java:127)
at com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl.getFile(TempDirTestFixtureImpl.java:78)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.copyFileToProject(CodeInsightTestFixtureImpl.java:446)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.copyFileToProject(CodeInsightTestFixtureImpl.java:420)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.configureByFileInner(CodeInsightTestFixtureImpl.java:1593)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.configureByFilesInner(CodeInsightTestFixtureImpl.java:1493)
at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.configureByFile(CodeInsightTestFixtureImpl.java:1500)
at insyncwithfoo.ryecharm.ruff.lsp.LanguageServerTest.test diagnostics - python file(LanguageServerTest.kt:57)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at com.intellij.testFramework.TestLoggerKt$recordErrorsLoggedInTheCurrentThreadAndReportThemAsFailures$2.invoke(testLogger.kt:99)
at com.intellij.testFramework.TestLoggerKt$recordErrorsLoggedInTheCurrentThreadAndReportThemAsFailures$2.invoke(testLogger.kt:99)
at com.intellij.testFramework.TestLoggerKt.recordErrorsLoggedInTheCurrentThreadAndReportThemAsFailures(testLogger.kt:81)
at com.intellij.testFramework.TestLoggerKt.recordErrorsLoggedInTheCurrentThreadAndReportThemAsFailures(testLogger.kt:99)
at com.intellij.testFramework.UsefulTestCase.lambda$wrapTestRunnable$15(UsefulTestCase.java:533)
at com.intellij.testFramework.UsefulTestCase.runTestRunnable(UsefulTestCase.java:426)
at com.intellij.testFramework.fixtures.BasePlatformTestCase.runTestRunnable(BasePlatformTestCase.java:117)
at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:442)
at com.intellij.testFramework.UsefulTestCase.lambda$runBare$13(UsefulTestCase.java:515)
at com.intellij.testFramework.EdtTestUtil.lambda$runInEdtAndWait$5(EdtTestUtil.java:92)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:240)
at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:25)
at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:202)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runIntendedWriteActionOnCurrentThread$lambda$7(AnyThreadWriteThreadingSupport.kt:319)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction$lambda$6(AnyThreadWriteThreadingSupport.kt:274)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWithTemporaryThreadLocal(AnyThreadWriteThreadingSupport.kt:204)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:274)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runWriteIntentReadAction(AnyThreadWriteThreadingSupport.kt:222)
at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.runIntendedWriteActionOnCurrentThread(AnyThreadWriteThreadingSupport.kt:318)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:928)
at com.intellij.openapi.application.impl.ApplicationImpl$4.run(ApplicationImpl.java:501)
at com.intellij.openapi.application.impl.AppImplKt.rethrowExceptions$lambda$2(appImpl.kt:66)
at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:102)
at com.intellij.util.concurrency.ChildContext$runInChildContext$1.invoke(propagation.kt:102)
at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:108)
at com.intellij.util.concurrency.ChildContext.runInChildContext(propagation.kt:102)
at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
at com.intellij.openapi.application.impl.AppImplKt.rethrowExceptions$lambda$3(appImpl.kt:77)
at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:105)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:117)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:43)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:781)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:728)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:750)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:585)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:482)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$12$lambda$11$lambda$10$lambda$9(IdeEventQueue.kt:307)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:864)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$12$lambda$11$lambda$10(IdeEventQueue.kt:306)
at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$3(IdeEventQueue.kt:958)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:117)
at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:958)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$12(IdeEventQueue.kt:301)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:341)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
@emrekultursay.1 Have you tried to override the method? LightPlatformCodeInsightFixture4TestCase is also a BasePlatformTestCase. A new project is created in the temp dir defined by the fixture.
@RunWith(JUnit4::class)
class GuessProjectDirTest : BasePlatformTestCase() {
override fun createTempDirTestFixture(): TempDirTestFixture = TempDirTestFixtureImpl()
override fun getTestDataPath() = "/tmp/"
@Test
fun testProjectDirectory() {
// This one works:
assertThat(project.basePath).doesNotContain("temp://")
// This one fails:
assertThat(project.guessProjectDir()!!.url).doesNotContain("temp://")
}
}
And here’s the error:
value of : getUrl()
expected not to contain: temp://
but was : temp:///src
at com.example.testing.GuessProjectDirTest.testGuessProjectDir(SimpleTest.kt:37)
I wasn’t entirely correct.
The temp dir fixture is used to create new files, but the project base directories (content roots) are created inside the temp:// file system.
If you want all of the data to be on disk, you need a heavy test case. But these are not as widely used and I haven’t seen a ready-made base class with a code insight fixture.