This week I started writing a few automated test cases for the jbehave eclipse plugin. I used Beck’s and Gamma’s “Contributing to Eclipse” as a starting point. They provide a simple test fixture that allows you to create java projects, packages and classes. I created a simple project with a trivial class and an even more trivial jbehave test case and launched the test case using the jbehave plugin. Then I wanted to verify the output that is been written to the console and my synchronsation problems started.
So I came up with two issues:
- Some things like the autobuild run in background jobs, so that you have got to wait for those jobs to finish before verifying. For the autobuild there is a simple solution:
- The second issue was around the update of the console, which happens in the UI thread. Unfortunatly the testcase runs in the UI thread as well, so a
Thread.sleep()won’t help. The key is calling Display’s
sleep()methods to get the event queue processed while waiting. It’s still a bit awkward to work with delays, but I couldn’t come up with a better way.