Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-ui-dev] unit testing long-running operations

Hello,

My colleagues at TJ Watson and I are developing some plugins that will
make some explorer contributions (similar to package explorer). I'm
writing some JUnit plugin tests for testing the functionality. I run
into some issues because some long running operations don't finish by
the time the test exercises them.

Consider this scenario:

- the setup method programatically creates a couple of projects into
the junit runtime workspace

- the test creates one more project and I want to assert that our tree
viewer part of explorer gets updated accordingly. Well, it does get
updated but it's hard to test this programatically. The test
runs/fails randomly, depending on how quickly the work gets done.
Sometimes the newly created project will get shown among the tree's
items in time. Other times the update doesn't get propagated by the
time the test asserts. On the production code, all references to the
tree are executed inside Display.asynExec.

I tried various things to make our test wait a bit until things get propagated: 
- I put Thread.sleep in the testing code (nasty)
- I put a waitForIndexer (a la Erich's "Contributing to Eclipse" book)

Still I am out of luck. Any suggestions are more than welcome.

thanks,
Danny


Back to the top