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

  • Problem
    State-expiration issues appear in production but not in development tests.
    Cause
    Real user scenarios (back button, tab duplication, new-tab reopen) are missing from test coverage.
    Solution
    Add E2E/integration cases that explicitly include stale/expired page interaction paths.
  • Problem
    AJAX tests pass but UI still breaks after rerender.
    Cause
    Tests validate component updates but skip JavaScript re-initialization after partial replacement.
    Solution
    Verify post-rerender client behavior, not only server-side AJAX response assertions.
  • Problem
    Users become stuck when session timeout happens mid-operation.
    Cause
    Timeout recovery and re-authentication paths were never tested in AJAX flows.
    Solution
    Create forced-timeout test scenarios and confirm clean return to login and recovery behavior.