FEST-Swing provides its own "applet viewer" to support GUI testing of Java applets. Testing an applet involves three steps: start the applet, the actual test and resource cleanup.
Starting the applet
There are two ways to start an applet:
1. Using an AppletLauncher to start an AppletViewer
The class AppletLauncher provides a fluent interface for launching an applet:
In addition, we can pass parameters to the applet to start. The parameters to pass are the same that are specified in the HTML "param" tag:
2. Starting an AppletViewer directly
AppletLauncher provides a simple and compact API to start applets in an AppletViewer. The created AppletViewer uses basic implementations of AppletStub and AppletContext though. If you need to test an applet with more advanced implementations of AppletStub or AppletContext, you can use AppletViewer directly, passing your own AppletStub (which will return your own AppletContext.)
Testing the applet
Once we have an AppletViewer up and running the applet to test, we simply can "wrap" the AppletViewer with a FrameFixture and start testing!
The following example tests an applet using TestNG:
Cleaning up resources
As our previous example showed, in addition to call cleanUp we need to unload the applet by calling unloadApplet in the AppletViewer used in our test.
3 Comments
Hide/Show CommentsJul 28, 2010
Zdenek Farana
Hi! I believe
mentioned above should be
Am I right?
Jul 28, 2010
Alex Ruiz
Thanks Zdenek, I just fixed it
Cheers!
Oct 25, 2010
jack jou
Hi,
Not sure if this is the right place to ask for help.
I am having difficulty to launch applets in browser using Appletviewer due to circular dependencies and other issues (please see the link: http://forums.oracle.com/forums/thread.jspa?messageID=5787909#5787909)
Do I have other options to connect and interact with my applets using FEST Swing? Please help.
Thanks.