Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unit testing applets

 
Allan Halme
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've inherited an applet that needs quite a bit of work. There are no unit tests. My question is, how to write unit tests for applets? What frameworks are there available?
Naturally, as much of the applet's code as possible should be placed into separate classes (that don't inherit java.applet.Applet), and thus those can easily be unit tested with JUnit.
However, there's still the concrete descendant of java.applet.Applet to test -- what options are there for this? Consider that there's already a couple of thousand lines of code implementing the applet, with no unit tests. I'd like to write unit tests to confirm the current behaviour of the applet, then I can happily refactor, making sure that all unit tests keep running.
[ January 15, 2004: Message edited by: Allan Halme ]
[ January 15, 2004: Message edited by: Allan Halme ]
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try instantiating the Applet class (possibly into a JFrame if it doesn't work alone), calling "doClick()" etc on whatever active elements you have in the GUI, and verify that the expected changes occurred in whatever panels/tables/lists you have.
And let us know if that (or something else) worked
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would advice to write Acceptance Tests instead of Unit Tests. Those are much less dependend on the internal structure of the application.
Take a look at http://fitnesse.org/ for a free tool.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does Fit(nesse) have built-in fixtures for testing applets? That would be an interesting (not to mention challenging) feature.
 
Allan Halme
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Acceptance testing is a good thing, but in this case, what I want to do is unit test the internal workings of the applet. It's just that right now it's a big monolithic chunk ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic