Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SWT/JFace and testing

 
J. B. Rainsberger
author
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks.
 
Matt Scarpino
author
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J.B.,

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
 
Stephen Holder
author
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic