Run an IdeaTestCase outside the AWT event thread and without a write lock

By default, IdeaTestCase runs tests on the AWT event thread while holding a write lock. This is convenient in most cases, but not always desirable. If you need to enqueue events onto the AWT thread and wait for them to execute (like when testing compilation), this can be a problem.

Due to lack of documentation for IdeaTestCase, as well as some assumptions that IdeaTestCase's setUp and tearDown methods make, it can be difficult to figure out how to avoid running on the event thread.

So, here's a test that runs on the JUnit thread, leaving the AWT event thread free for enqueuing and executing runnables. Thanks to Eugene Vigordchik for the tip.

0

Hi Dimitry,

Bringing the discussion back to our original problem.

We want to test certain actions on the event Queue by waiting for those actions as described in http://devnet.jetbrains.net/message/5176841

The default model of IdeaTestCase does not allow that since tests run in the AWT event thread.

Please advise on how we can write tests that wait for events on the queue in Intellij 10.x since without that we cannot port our plugin tests to Intellij 10.

thanks
Siddharth

0

Hello Siddharth,

You can use the IdeEventQueue.flushQueue() method to let the Runnables which
have been invokeLater()'ed execute.

Bringing the discussion back to our original problem.

We want to test certain actions on the event Queue by waiting for
those actions as described in /message/5176841

The default model of IdeaTestCase does not allow that since tests run
in the AWT event thread.

Please advise on how we can write tests that wait for events on the
queue in Intellij 10.x since without that we cannot port our plugin
tests to Intellij 10.


--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

请先登录再写评论。