I'm taking another shot at updating from 1.5.7 to 1.5.8, so that
hopefully I can eventually update to 6.
I've made the massive number of expectation changes to reflect how
WicketTester now calls the page objects, but some tests still fail. On
some investigation, I found that weird stuff is going on, but I'm not
sure whether it's a bug.

Here's an example of one of the failing form tests:

    @Override
    public void testDeleteForm() {
        tester.startPage(ShowGroupPage.class, new
PageParameters().add("id", "3"));
        tester.assertRenderedPage(ShowGroupPage.class);

        FormTester deleteGroupForm = tester.newFormTester("deleteGroupForm");

        deleteGroupForm.submit();

        tester.assertRenderedPage(GroupsPage.class);
        tester.assertInfoMessages("Group my-group deleted.");
    }

ShowGroupPage in particular does use the parameters. In particular,
parameter "id" is necessary to load the group the page is displaying.
Many of the failing tests (if not all) seem to be of the same form.

    public ShowGroupPage(PageParameters parameters) {
        initGroup(findGroup(parameters));
    }

In Wicket 1.5.7, the test passes.
In Wicket 1.5.8, deleteGroupForm.submit() fails because the "id"
parameter is missing.

Digging a bit deeper, I find that `ShowGroupPage` is being instantiated twice:

1. Once during `tester.startPage`, with `PageParameters` being the
ones I originally passed in.
2. Once during `deleteGroupForm.submit`, with `PageParameters` being empty.

The form itself hides the id=3 as a hidden HTML form field. In Wicket
1.5.7, it wasn't recreating the page object at all. In Wicket 1.5.8,
it's instantiating the page, but apparently never setting any of the
form parameters.

So I'm confused. Is the way we're calling WicketTester incorrect here?
Or is the Page implementation incorrect?

I have also tried:
* Later versions of 1.5.x
* Overriding onInitialize() instead of the constructor
* Overriding WicketTester to programmatically add the hidden field
values to the FormTester when it's created

TX

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to