|
Re: Difference of click() in the test thread vs. wrapping its execution in syncExec()? [message #1410617 is a reply to message #1410601] |
Thu, 21 August 2014 08:01   |
|
When you hit click or whatever UI action, events are sent
asynchronously, just like they are in real life. When you're clicking
manually, it takes some milliseconds before a pop-up is shown as a
response (for example), so it seems immediate to you.
But for a Java program, some milliseconds is far from being immediate,
so that when the next instruction (assert) is run, the event has not
been processed yet, and the state of the application is probably not
changed yet.
That's why checks should be asynchronous as well. I suggest you replace
you assert by a bot.waitUnit(condition) and put your check in condition.
That will asynchronously check for your condition multiple times until
it gets evaluated to true, and if nothing ever happens, it will fail
gracefully similarly to an assert.
Note that since the finders are asynchronous, you can chain most SWTBot
instructions such as 'bot.button("open blah").click();
bot.shell("blah").close()' and bot.shell("blah") won't fail as it will
wait for the widget to appear.
HTH
--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
|
|
|
Re: Difference of click() in the test thread vs. wrapping its execution in syncExec()? [message #1410631 is a reply to message #1410617] |
Thu, 21 August 2014 08:49  |
Erdal Karaca Messages: 854 Registered: July 2009 |
Senior Member |
|
|
Thanks, Mickael and sorry if that question was already asked a few posts earlier.
I believe it is a bit of work to get familiar with how UI testing works when switching from pure unit testing...
Mickael Istria wrote on Thu, 21 August 2014 10:01When you hit click or whatever UI action, events are sent
asynchronously, just like they are in real life. When you're clicking
manually, it takes some milliseconds before a pop-up is shown as a
response (for example), so it seems immediate to you.
But for a Java program, some milliseconds is far from being immediate,
so that when the next instruction (assert) is run, the event has not
been processed yet, and the state of the application is probably not
changed yet.
That's why checks should be asynchronous as well. I suggest you replace
you assert by a bot.waitUnit(condition) and put your check in condition.
That will asynchronously check for your condition multiple times until
it gets evaluated to true, and if nothing ever happens, it will fail
gracefully similarly to an assert.
Note that since the finders are asynchronous, you can chain most SWTBot
instructions such as 'bot.button("open blah").click();
bot.shell("blah").close()' and bot.shell("blah") won't fail as it will
wait for the widget to appear.
HTH
--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
|
|
|
Powered by
FUDForum. Page generated in 0.02141 seconds