jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes SWT/JFace and testing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "SWT/JFace and testing" Watch "SWT/JFace and testing" New topic

SWT/JFace and testing

J. B. Rainsberger
Ranch Hand

Joined: Aug 05, 2004
Posts: 87
Welcome to the authors!

It's no secret that my primary interest in any software package, framework or platform has to do with designing for testability. Do you have an opinion as to how well SWT/JFace mesh with, say, a test-driven development approach? In particular, is it any easier to test SWT/JFace-based UIs in isolation from the rest of the application than, say, Swing/AWT? If so, can you give an example?


Author of <a href="http://www.amazon.com/exec/obidos/ASIN/1932394230/ref=jranch-20" target="_blank" rel="nofollow">JUnit Recipes: Practical Methods for Programmer Testing</a>
Matt Scarpino

Joined: Jan 17, 2005
Posts: 7

Steve can probably answer this better, but I'll give it a shot. I've used JUnit and JFCUnit, but I haven't explored SWT testability.

Eclipse provides a plug-in called org.eclipse.swt.tests that you can download from their CVS site. This contains many, many JUnit tests for SWT widgets and you can customize them for your use. There's a similar package for org.eclipse.jface.tests.

Also, the Eclipse Test & Performance Tools project is shaping up to test everything Eclipse-related and more. I don't know if it's ready for prime time, but it's worth investigating.

I'll keep looking though, and I'll keep you posted if I find anything.

Matt Scarpino

Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1932394273/ref=jranch-20" target="_blank" rel="nofollow">SWT/JFace in Action</a>
Stephen Holder

Joined: Jan 14, 2005
Posts: 10
Hi J.B.-

I actually don't have a whole lot to add, Matt's recommendations are probably the best place to look in terms of getting ideas.

As for a comparison with Swing, to be honest I've never really come up with a good strategy for unit testing UI components, whether Swing/SWT/Web based/whatever. Maybe I should check out your book . I'd guess that you'll have approximately the same issues in running tests against SWT components as you would against Swing. Using JFace and the Viewer framework does make testing some things fairly straightforward, because you can test LabelProviders, Sorters, Filters, ContentProviders etc. on their own, but there still isn't any good way that I know of to test the actual widgets that eventually get displayed to the user.

Stephen Holder<br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1932394273/ref=jranch-20" target="_blank" rel="nofollow"><i>SWT/JFace in Action</i></a>
I agree. Here's the link: http://aspose.com/file-tools
subject: SWT/JFace and testing
It's not a secret anymore!