Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Using SWTBot for Eclipse tutoring
Using SWTBot for Eclipse tutoring [message #1287229] Mon, 07 April 2014 15:00 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I'm responsible for an introductory course in object-oriented
programming with Java. I recomment using Eclipse for the assignments,
but find that too few students learn to use it properly, in particular
setting up projects with jars correctly, setting breakpoints and running
the debugger, etc. Now we're considering using SWTBot for stimulating
the student to improve their Eclipse skills, e.g. by testing that they
can perform certain procedures and helping them by providing "cheat"
buttons that perform common procedures for them.

My current idea is to implement a state machine where the states are
descriptions of UI structures that are present and active, and the
transitions are the appearance and activation of new UI structures. A
panel will indicate the current state, and some states may provide
buttons for helping you reach the next state. The difference between
this and a UI test is (among others) that the state machine will run in
parallel with the user's interaction and have to accept intermediate
actions that may take a long time complete.

Do you think SWTBot is appropriate for this? Any pitfalls, e.g. thread
handling, timeouts while waiting etc?

To make it easier to write the state machine, I'm considering writing a
DSL using Xtext (which I know well). Has anyone tried something similar?

Regards,

Hallvard Trætteberg
Associate Professor, Dept. of Computer and Information Science.
Norwegian Univ. of Science and Technology.
Re: Using SWTBot for Eclipse tutoring [message #1288250 is a reply to message #1287229] Tue, 08 April 2014 11:57 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 04/07/2014 05:00 PM, Hallvard Trætteberg wrote:
> timeouts while waiting etc?

By default, when a widget isn't immediately available, SWTBot waits for
a given timeout before failing. In case the timeout isn't good, it's
possible to change it in several different ways.
In many cases, it's ok to rely on default timeout.

But I wouldn't recommend relying too much on timeout for long-running
operations, as their duration can widely change from an environment to
the other.
SWTBot provides some ways to wait for a specific condition to happen.
For example, for example to wait while a ProgressMonitorDialog is
active. That's a more recommended way to deal with long-running operations.

HTH
--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: Using SWTBot for Eclipse tutoring [message #1289293 is a reply to message #1288250] Wed, 09 April 2014 07:38 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Mickael,

Thanks for your answer! In such a "monitoring" case, if a widget doesn't
appear within a certain time, it is not necessarily a failure in the
testing sense. The user may have gone for lunch and will continue later,
or has decided to skip a task.

There are different ways of waiting for changes in the UI:
- use a timeout
- continuously poll, with a delay between each
- add an appropriate listener

My guess is that the third variant is best, but only a few conditions
can be directly waited for in this way. E.g. there is a dispose event,
but I haven't found any event for the case when a widget is added to the
hierarchy.

Hallvard

On 08.04.14 13:57, Mickael Istria wrote:
> On 04/07/2014 05:00 PM, Hallvard Trætteberg wrote:
>> timeouts while waiting etc?
>
> By default, when a widget isn't immediately available, SWTBot waits for
> a given timeout before failing. In case the timeout isn't good, it's
> possible to change it in several different ways.
> In many cases, it's ok to rely on default timeout.
>
> But I wouldn't recommend relying too much on timeout for long-running
> operations, as their duration can widely change from an environment to
> the other.
> SWTBot provides some ways to wait for a specific condition to happen.
> For example, for example to wait while a ProgressMonitorDialog is
> active. That's a more recommended way to deal with long-running operations.
>
> HTH
Re: Using SWTBot for Eclipse tutoring [message #1289787 is a reply to message #1289293] Wed, 09 April 2014 16:41 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 04/09/2014 09:38 AM, Hallvard Trætteberg wrote:
> Mickael,
>
> Thanks for your answer! In such a "monitoring" case, if a widget doesn't
> appear within a certain time, it is not necessarily a failure in the
> testing sense. The user may have gone for lunch and will continue later,
> or has decided to skip a task.

I'm confused. Are you speaking about test execution or test recording?

In case of test execution, there is no user, the Test drives the
application. Code doesn't need to lunch nor take a break and just does
what it's told to do.

If you're speaking about test recording, then SWTBot Recorder plugs a
listener (addFilter) on the SWT event loop and intercepts some
meaningful events to deduce the UI actions that were actually made and
triggered these events. From the set of events, it deduces a piece of
code that would have the same effect.
The recorder doesn't understand the concept of waiting. If several hours
happen between 2 events, it's not smart enough to figure out the reason
of this delay (was it a frozen UI, wait for something to appear, or wait
for another external application to start, or just the user felt
asleep...). In case of complex delays, user has to augment the generated
code to add the wait conditions. User is free to decide how the test
should wait: one can put a listener on the event loop that will pause
the test until a widget shows up, or just wait 5 seconds for a widget by
polling every 50ms, or wait to receive a websocket notification...

Although it's somehow easy to automatically figure out what happened,
it's way more difficult to find what didn't happen and to deduce smart
wait conditions.
Currently, SWTBot Recorder just assumes that wait conditions are the
responsibility of the developer that will take care of this test.
--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: Using SWTBot for Eclipse tutoring [message #1290571 is a reply to message #1289787] Thu, 10 April 2014 08:29 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 09.04.14 18:41, Mickael Istria wrote:
> On 04/09/2014 09:38 AM, Hallvard Trætteberg wrote:
>> Mickael,
>>
>> Thanks for your answer! In such a "monitoring" case, if a widget doesn't
>> appear within a certain time, it is not necessarily a failure in the
>> testing sense. The user may have gone for lunch and will continue later,
>> or has decided to skip a task.
>
> I'm confused. Are you speaking about test execution or test recording?

Neither, that's why I had to ask ;-)

The use case is teaching students to use Eclipse for various tasks. A
task pane tells the user to perform a certain task and then monitor the
state of Eclipse to see if the students does it correctly, e.g. switches
to the right perspective, opens the correct pane, executes the required
command and click on the required line in a list. For each step there
may be a button that does the step for the student.

SWTBot should be able to help with checking the state of Eclipse and
altering it, but I guess the waiting part will be a problem, since it
may take a lot of time and may be interleaved with other tasks. A mixed
approach may work better:
- periodical polling with timeout
- listening to important events, like the opening of parts etc.

Hallvard
Re: Using SWTBot for Eclipse tutoring [message #1290912 is a reply to message #1290571] Thu, 10 April 2014 14:53 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

So the use-case is to put "probes" in an RCP application to make sure
the right usage events have happened?
Similarly to what Microsoft did for their gamified Office tutorial with
Clippy giving you points when you do what it tells you?

In such case, I think it's out of the scope of SWTBot, and that should
probably be a separated project.
A dummy but probably good enough implementation is to add Filters on the
various event loops with the events you want to see (a shell opening
with right title...) and when a "milestone" is achieved, replace it by
the another listener for the next milestone...

Example;
* Filter 1 will wait for shell with title "New Project" to open
* Filter 2 would wait for a button "Finish" to be selected when the
first text widget of the same Shell contains text "myProject"
* Filter 3 would wait for View with title "myFile" to be open
So you start by putting Filter 1, when Filter 1 condition is met, you
remove it and you put filter 2, when Filter 2 condition is met, you
remove it and you put filter 3, etc...

This is actually a quite interesting project. If you can make it generic
enough, it would be cool to have it at Eclipse.org ;)
--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: Using SWTBot for Eclipse tutoring [message #1291724 is a reply to message #1290912] Fri, 11 April 2014 06:56 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
On 10.04.14 16:53, Mickael Istria wrote:
> So the use-case is to put "probes" in an RCP application to make sure
> the right usage events have happened?
> Similarly to what Microsoft did for their gamified Office tutorial with
> Clippy giving you points when you do what it tells you?

Exactly, learning Eclipse meets gamification!

> In such case, I think it's out of the scope of SWTBot, and that should
> probably be a separated project.
> A dummy but probably good enough implementation is to add Filters on the
> various event loops with the events you want to see (a shell opening
> with right title...) and when a "milestone" is achieved, replace it by
> the another listener for the next milestone...

Yes, that's a possible design. Some SWTBot functionality should be
useful, like locating specific UI elements, performing tasks when the
user is stuck etc.

> Example;
> * Filter 1 will wait for shell with title "New Project" to open
> * Filter 2 would wait for a button "Finish" to be selected when the
> first text widget of the same Shell contains text "myProject"
> * Filter 3 would wait for View with title "myFile" to be open
> So you start by putting Filter 1, when Filter 1 condition is met, you
> remove it and you put filter 2, when Filter 2 condition is met, you
> remove it and you put filter 3, etc...

I think a state machine will work: When you enter a state you add the
filters, and then when a filter triggers a transition, they are removed
and new ones added for the next state. If the user is stuck and uses a
"cheat" button, the state machine will happily keep running.

> This is actually a quite interesting project. If you can make it generic
> enough, it would be cool to have it at Eclipse.org ;)

The goal is to make a prototype that supports a couple of relevant use
cases and generalize as much as time allows. Hopefully the result is
good and interesting enough for a contribution.

Hallvard
Previous Topic:SWTBot for existing RCP application
Next Topic:Troubles with pressShorcut
Goto Forum:
  


Current Time: Tue Mar 19 07:54:24 GMT 2024

Powered by FUDForum. Page generated in 0.01906 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top