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 ]
<i>The lyf so short, the craft so long to lerne.</i> --Geoffrey Chaucer (c. 1343-1400)
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
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.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Jan 23, 2002
Does Fit(nesse) have built-in fixtures for testing applets? That would be an interesting (not to mention challenging) feature.
Joined: Aug 22, 2003
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 ...