Chapter 13: Trials and Verification - Submit your code to judgment
"Faith without tests is noise. Let WicketTester weigh your work."- Wicket Scripture
Why Test
Wicket's component model makes UI behavior testable at the Java level. This lets you validate rendering, events, and validation rules without a real browser.
Test Setup
Maven dependency
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-tester</artifactId>
<version>10.8.0</version>
<scope>test</scope>
</dependency>Page Rendering Tests
Start pages with WicketTester and assert visible component trees and expected text output.
Form Tests
Use FormTester to set values, submit forms, and verify both success messages and validation failures.
AJAX Tests
Execute AJAX events and verify target components are updated correctly.
Practical Pitfalls
-
ProblemState-expiration issues appear in production but not in development tests.CauseReal user scenarios (back button, tab duplication, new-tab reopen) are missing from test coverage.SolutionAdd E2E/integration cases that explicitly include stale/expired page interaction paths.
-
ProblemAJAX tests pass but UI still breaks after rerender.CauseTests validate component updates but skip JavaScript re-initialization after partial replacement.SolutionVerify post-rerender client behavior, not only server-side AJAX response assertions.
-
ProblemUsers become stuck when session timeout happens mid-operation.CauseTimeout recovery and re-authentication paths were never tested in AJAX flows.SolutionCreate forced-timeout test scenarios and confirm clean return to login and recovery behavior.