I am relatively new to SWTBot for Tool Testing.I am runing JUnit Test case where TestCase should run on selection of project and files in the project should be loaded before the test case starts executing but Testcase starts executing without waiting for the Loading Process.
Loading of the files in the project was provided by Eclipse (Plugin :-org.eclipse.sphinx.emf.workspace.loading ) using ProgressBar.
By surfing through the Internet i have foundout
bot.waitUntil() is used to halt TestCase if any operation have to be completed before proceeding further. I have tried multiple options but unable to get the result i was expecting.
Can any one help me on this one
I advise you to call:
instead of using
bot.waitUntil. It should block the current thread (i.e. your test) until the file loading is done.The Progress View is automatically filled by the Eclipse UI when Eclipse Jobs are running in background. In your case, those jobs are scheduled by the LoadJobScheduler. The idea is to directly use Eclipse's Jobs API to wait for those jobs to end instead of querying the UI. This is exactly what
Job.getJobManager().joindoes, see also this answer.Preventing infinite loops
Since
joinis blocking it might lead to infinite loops. You can useJobManager::findto check running jobs without blocking the thread:With the code above, SWTBot will throw a
TimeoutExceptionif Jobs are still found running after a few seconds.