Make the NodeTestCase to wait for the completion of EDT threads

Consider I have a java class which uses EDT for processing some nodes.


Now when i use this method inside NodeTestCase as, 


The test does not wait for the completion of the other EDT threads. So the test gives undesired results. Is it possible to make the current test thread to wait, till the completion of EDT threads?

1
1 comment
Avatar
Permanently deleted user

First of all, you need to be very careful when dealing with threads explicitly. Generally, your nodes/models shall not depend on specific thread, especially EDT one, as it's designated for UI actions, and, therefore, it's odd for headless tests to deal with EDT. Nevertheless, if you absolutely need to depend from EDT, you can wrap your test method with ThreadUtils.runInUIThreadAndWait(), and use 'command' statement (i.e. command with project.getRepository {}) from within the runnable, which is synchronous command execution (unlike 'execute command in EDT', which is asynchronous).

 

1

Please sign in to leave a comment.