Unit testing of the GUI is not the same as unit testing through the GUI. We are interested in the logic of the GUI rather than the placement and order of the GUI widgets on screen.
Testing the logic makes the tests less sensitive to changes in presentation but introduces the problem of JavaScript dependent features. AJAX is in the vogue so we wish to be able to do testing of that too without being forced to start a browser. There is some support for AJAX in Wicket that may be reached using the test framework that is part of Wicket. However, it is not straightforward to use and there are some pitfalls.
Here are three examples of avoiding those, one for each of the check box, drop down and radio group controls.
The examples are “canned” in that the demonstration of them is packed as a web application.
The source is available at github: http://github.com/perty/wicket-test-examples.
The idea is that download the source, then run “mvn install” followed by “mvn jetty:run”.
That will start a Jetty servlet container. Point your browser to http://localhost:8080/wicket-test-examples/ and continue reading.
Can’t be bothered?
Well, the short version is: there are different approaches you must take for each of the check box, drop down and radio group controls when you test them. Furthermore, you want to asure two things when testing Wicket with AJAX; assert that correct components are added and that the markup identity is set.
Now, off you go and download the code! 🙂
Coolt with real code!
Wonderful contribution (especially the code). Thank you!