assertIsWriteThread fails when calling copyDirectoryToProject
Answered
I want to write a unit test for my plugin. The plugin retrieves information from git, so I want a .git directory in the test project. I have created a directory `testData/single/dot_git` in my plugin's directory, and I have the following test:
public class TestGitLink extends BasePlatformTestCase {
@Override
@BeforeEach
protected void setUp() throws Exception {
super.setUp();
this.myFixture.copyDirectoryToProject("dot_git", ".git");
}
@Override
@AfterEach
protected void tearDown() throws Exception {
super.tearDown();
}
@Test
public void testSomethign() {
assertEquals("", getTestDataPath());
}
@Override
protected String getTestDataPath() {
return "testData/single/";
}
}
When I run this test, it fails with the following error:
com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: EventQueue.isDispatchThread()=false Toolkit.getEventQueue()=com.intellij.ide.IdeEventQueue@51f9a9a4 Current thread: Thread[Test worker,5,main] 778739793 Write thread (volatile): Thread[AWT-EventQueue-0,6,main] 329367088com.intellij.openapi.diagnostic.Attachment@669a08db at com.intellij.openapi.application.impl.ApplicationImpl.assertIsWriteThread(ApplicationImpl.java:1058) at com.intellij.openapi.application.impl.ApplicationImpl.startWrite(ApplicationImpl.java:1140) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:945) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:968) at com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl.copyAll(LightTempDirTestFixtureImpl.java:81) at com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl.copyAll(LightTempDirTestFixtureImpl.java:76) at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.copyDirectoryToProject(CodeInsightTestFixtureImpl.java:449)
The similar `copyFileToProject` does not raise an exception. My test runs as expected if I don't call `copyDirectoryToProject`. What is going on? Do I have to do something before I copy a directory?
Please sign in to leave a comment.
What is your target platform?