|
|
|
|
|
Re: Got feedback about SWTBot ? [message #44457 is a reply to message #44334] |
Tue, 21 July 2009 11:41 |
Pascal G Messages: 157 Registered: July 2009 |
Senior Member |
|
|
Steven Chamberlin wrote:
>> The worst issue I had so far when writing tests with SWTBot is
>> synchronization issues. It's easy to try to synchronize your testing
>> thread with the UI thread and doing it the wrong way. I had to do
>> multiple iteration to achieve something relatively stable and
>> (hopefully) inside the good practice guidelines. Most of the time this
>> happened when I had to validate the state of the UI.
>
> Hi Pascal / Ketan,
>
> I found this interesting. I wonder if it might be related to my issue.
>
> The biggest pain point I am currently experiencing with SWT-Bot is that
> I am experiencing random intermittent failures in my test code that seem
> to be related to some kind of timing / synchronization issue. Code that
> previously worked in a prior run will fail with
> org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundExcep tion: The
> widget was null.
>
> at different places in the code. ...then I'll run it again and it'll be
> fine.
>
> Anyone else experience this and anyone have tips about how to fix these
> kinds of intermittent issues? I wonder if it might be because the UI is
> locked up due to some busy function/job on the ui thread. I think
> Eclipse might get in a busy state, similar to when the UI is temporarily
> frozen due to some 'long' running function/job on a UI thread. Is there
> a utility for checking or handling such a situation, or could this be
> built in to SWT-Bot itself? Why doesn't SWT-Bot keep trying until the
> timeout period is expired?
>
> If my testcases fail on their own intermittently because of timing
> issues in the framework or Eclipse, then I will have a lot of false
> negatives and the solution would not be workable / scalable.
> Suggestions very much appreciated ... Thanks!
>
> -- Steve
>
>
I had this issue myself with certain of my tests. One of the problem I
had was with the Display.post() method in eclipse 3.4 on Linux/GTK: it
caused a deadlock in the UI thread and I has to restart the tests. It
got fixed in eclipse 3.5 so now I'm running with 3.5.
The other issue I had was with the update of the UI was slower then I
had expected. The biggest pain I had was with a JFace TreeViewer with
columns, which was populated each time my underlying model changed. I
wasn't doing any synchronization prior to check the UI state. For
exemple, each time I changed something in the model, I did this kind of
check:
// Change the model with some action: model.setFoo("bar");
SWTBotTreeItem item = bot.tree().getTreeItem("foo");
assertEquals("The model was not changed!", item.cell(2), "bar");
This sometime worked, sometime it threw WidgetNotFoundException, and
sometime it was SWTError: Widget is disposed. What I do now instead is:
bot.waitUntil(new DefaultCondition()
{
public boolean test() throws Exception
{
SWTBotTreeItem item = bot.tree().getTreeItem("foo");
return item.cell(2).equals("bar");
}
public String getFailureMessage()
{
return "The model was not changed!";
}
}
This method has the advantage of synchronizing with the UI, as the
condition will be tried periodically until the default timeout happens,
which is 5 seconds. If the 5 seconds is not enough, then you can make it
longer by changing SWTBotPreferences#TIMEOUT. Of course, if you have a
long running job in the UI thread then the problem is not really with
your tests, but with the design of that job. I also don't think there is
direct support for checking long running job (with a progress monitor
and all, such as the synchronizing with CVS job) in SWTBot, but I'm
pretty sure there is a quick workaround for this.
Hope this helps
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/
*Because performance matters.*
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10718 seconds