Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Any tips on using jUnit to test RCP application?
Any tips on using jUnit to test RCP application? [message #435432] Thu, 18 August 2005 12:21 Go to next message
Babu is currently offline BabuFriend
Messages: 4
Registered: July 2009
Junior Member
Hi,

I am just about to start on an RCP application. I am fairly famililar with
jUnit -- but not with Eclipse PDE/SWT/RCP development a great deal.

I am looking for suggestions on best practices to test the *UI code*. Most
certainly, I will have my own small wrapper (or Beans if you will) on top
of RCP widgets which will be used in my application(s) and I expect to
very rarely call org.eclipse.* stuff directly from my application(s).

Any hints towards existing plugin test code will also be very helpful.

Best regards
- Babu
http://vsbabu.org/
PS: I am new to RCP; but from what I've seen, it is really nice (nothing
that you guys didn't know already :-))
Re: Any tips on using jUnit to test RCP application? [message #435598 is a reply to message #435432] Fri, 19 August 2005 07:52 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
I think the best practices are not to test the UI code directly (e.g. don't try to simulate clicking on a button) but instead test the code that the UI components should call. For example, if you want to find out whether the right properties are being displayed in a PropertiesView, test the actual IPropertySource object directly instead of the PropertiesView contents. It's got a fairly simple interface (as have most UI hooks in Eclipse) so it shouldn't be difficult to test them separately.

You can also write/run JUnit tests in a run-time workspace if you need extra features (e.g. access to the Workspace stuff) in your tests as well.
Re: Any tips on using jUnit to test RCP application? [message #435623 is a reply to message #435598] Fri, 19 August 2005 08:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: joerg.von.frantzius.artnology.nospam.com

Alex Blewitt schrieb:

>I think the best practices are not to test the UI code directly (e.g. don't try to simulate clicking on a button) but instead test the code that the UI components should call. For example,
>
I'd say simulating button clicks etc. is what you really need here. How
else do you want to test that the event wiring in your application is
correct? I heard somewhere that there might be a highly expensive
product from Rational for this problem.

>if you want to find out whether the right properties are being displayed in a PropertiesView, test the actual IPropertySource object directly instead of the PropertiesView contents. It's got a fairly simple interface (as have most UI hooks in Eclipse) so it shouldn't be difficult to test them separately.
>
>You can also write/run JUnit tests in a run-time workspace if you need extra features (e.g. access to the Workspace stuff) in your tests as well.
>
>
Re: Any tips on using jUnit to test RCP application? [message #435630 is a reply to message #435623] Fri, 19 August 2005 13:11 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
> I'd say simulating button clicks etc. is what you really need here. How
> else do you want to test that the event wiring in your application is
> correct? I heard somewhere that there might be a highly expensive
> product from Rational for this problem.

Yes, and it's Rational that's pushing the idea that the wiring needs testing. Plus, it only works on Windows systems, and generally has problems with Java applications -- I'm not even sure that it works with SWT.

The point is that it is very rare that it's a problem with the wiring; things like that just tend not to break as the lifetime of a system evolves. I mean, you've put it in and tested the wiring at least once manually when it was being developed, yes? Mostly, it's just a wrapper like:

widget.addSomeSortOfListener() {
new SomeSortOfListener() {
public void someListenerMethod() {
doRealAction();
}
}
}

So instead of trying to get the exact point-and-click nature of the buttons, you can just test the doRealAction() method instead. Additionally, it makes it more robust because if the doRealAction() is used elsewhere, you've tested that individual for anything (e.g. MenuItems) that can call it directly.

To be honest, the main problem is not the wiring but instead it is the Thread access -- there's a bunch of things that you can/can't do in the main SWT processing thread (particularly changes during a modification event). (see http://help.eclipse.org/help30/topic/org.eclipse.platform.do c.isv/guide/swt_threading.htm for more info)
Re: Any tips on using jUnit to test RCP application? [message #435632 is a reply to message #435623] Fri, 19 August 2005 13:31 Go to previous messageGo to next message
Babu is currently offline BabuFriend
Messages: 4
Registered: July 2009
Junior Member
Thanks guys...

I think I will check out Perl Win32:GuiTest first
(http://www.perl.com/pub/a/2005/08/11/win32guitest.html). Not expensive,
but I need to think about how to get a bunch of Java programmers to think
Perl :-) Personally, I'd have preferred Python or Ruby.

Regards
- Babu
Re: Any tips on using jUnit to test RCP application? [message #435636 is a reply to message #435598] Fri, 19 August 2005 16:46 Go to previous messageGo to next message
Cedric Hyppolite is currently offline Cedric HyppoliteFriend
Messages: 22
Registered: July 2009
Junior Member
Alex Blewitt wrote:
> I think the best practices are not to test the UI code directly (e.g. don't try to simulate clicking on a button) but instead test the code that the UI components should call. For example, if you want to find out whether the right properties are being displayed in a PropertiesView, test the actual IPropertySource object directly instead of the PropertiesView contents. It's got a fairly simple interface (as have most UI hooks in Eclipse) so it shouldn't be difficult to test them separately.
>
> You can also write/run JUnit tests in a run-time workspace if you need extra features (e.g. access to the Workspace stuff) in your tests as well.

Hi,

Do you have any documentation pointers on the 'JUnit tests in a run-time
workspace' part ?

Thanks,
Cédric
Re: Any tips on using jUnit to test RCP application? [message #435651 is a reply to message #435432] Sat, 20 August 2005 21:21 Go to previous messageGo to next message
Marc Heimann is currently offline Marc HeimannFriend
Messages: 18
Registered: July 2009
Junior Member
Have a look at http://today.java.net/today/2004/02/02/ch12Eclipse.pdf

Cheers
Marc

Babu wrote:

> Hi,
>
> I am just about to start on an RCP application. I am fairly famililar
> with jUnit -- but not with Eclipse PDE/SWT/RCP development a great deal.
> I am looking for suggestions on best practices to test the *UI code*.
> Most certainly, I will have my own small wrapper (or Beans if you will)
> on top of RCP widgets which will be used in my application(s) and I
> expect to very rarely call org.eclipse.* stuff directly from my
> application(s).
>
> Any hints towards existing plugin test code will also be very helpful.
>
> Best regards
> - Babu
> http://vsbabu.org/
> PS: I am new to RCP; but from what I've seen, it is really nice (nothing
> that you guys didn't know already :-))
>
Re: Any tips on using jUnit to test RCP application? [message #435663 is a reply to message #435630] Mon, 22 August 2005 09:22 Go to previous message
Eclipse UserFriend
Originally posted by: joerg.von.frantzius.artnology.nospam.com

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Alex Blewitt schrieb:
<blockquote
cite="mid480676.1124457122548.JavaMail.root@cp1.javalobby.org"
type="cite">
<blockquote type="cite">
<pre wrap="">I'd say simulating button clicks etc. is what you really need here. How
else do you want to test that the event wiring in your application is
correct? I heard somewhere that there might be a highly expensive
product from Rational for this problem.
</pre>
</blockquote>
<pre wrap=""><!---->
Yes, and it's Rational that's pushing the idea that the wiring needs testing. Plus, it only works on Windows systems, and generally has problems with Java applications -- I'm not even sure that it works with SWT.
</pre>
</blockquote>
Right, I don't know neither. I'd still like to test the wiring, even if
that wish astoundingly conforms to Rational marketing ;)<br>
I've got an RCP application here that has a lot of state to keep in the
UI. For one there is things like enabling and disabling actions based
on selections, e.g. a delete-button that can cause a list and thus its
selection to become empty, which in turn disables actions, and then
there is stuff like two windows with the selection in one window
causing the second window to change display and action enablement. <br>
<br>
There is enough that can go wrong in the UI, so I really want to have
my handful of use-cases being clicked through the application,
hopefully without having to train any monkeys, or me becoming the click
monkey.<br>
<br>
I just see that this is not the thread that had Abbot mentioned in it;
somewhere someone posted about experiences with that and it sounded
promising although not ready for production use. Digging for it I just
found some posts in eclipse.tools.hyades saying that IBM had extended
Abbot and wanted to make that open source.<br>
</body>
</html>
Previous Topic:-Dosgi.parentClassloader=ext - Error
Next Topic:starting 2nd RCP from first
Goto Forum:
  


Current Time: Sat Dec 07 15:50:30 GMT 2024

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

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

Back to the top