Canned Wicket Test Examples

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

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! ūüôā

3 Comments

  • 1
    Mattias Skarin
    2010-07-12 - 12:59 | Permalink

    Coolt with real code!

  • 2
    Brian Westrich
    2010-10-28 - 02:16 | Permalink

    Wonderful contribution (especially the code). Thank you!

  • 3
    2012-10-07 - 14:47 | Permalink

    […] had to be changed. And I wasn’t worried as I was backed by tests! I wrote earlier about this (http://blog.crisp.se/2010/06/20/perlundholm/canned-wicket-unit-test-examples). This time I added styling which of course consumed lots of time since ¬†a certain widely used […]

  • Leave a Reply

    Your email address will not be published. Required fields are marked *