Skip to end of metadata
Go to start of metadata

Unit Test

Unit testing with Wicket is done by mocking the application. This means that you do not have a webserver running. This section will be about how to get started using unit testing with Wicket's testing framework.

Simple example

Above example makes sure that your page can render. This in itself is a very powerful test & and should be the minimum of tests on all your pages (in this author's opinion).

Basic Test Case for some labels and elements ...

Note that in above test, should you have panel without a default constructor, then you'd have to do the following :

Similiar to above, if you have a page without a default constructor; you would do the same; this time creating an anonymous ITestPageSource implementation.

In above test, as you can make out, first a WicketTester class is instantiated, This would create a DummyWebApplication instance, which will have new SessionStore, Response etc. and a DummyHomePage in it. A call to startPage method on wicket Tester initiates the cycle. First Mock request and response are setup,then a new RequestCycle is created followed by regular request processing (for details see Lifecycle section of documentation).

A note on paths : As in above assertLabel( ) we have to precede the actual label name or component name with container,in this case a panel.

  • No labels