You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Stijn Niclaes <st...@gmail.com> on 2011/10/25 15:01:38 UTC

WicketTester.startComponentInPage changed again in 1.5.2?

Last week I updated our project to 1.5.1. Did not encounter big problems,
but did have quite a bit of deleting to do in unit tests for Panels:
In 1.4.15 I tested my panels using implementations of TestPanelSource.

class SomePanelSource implements TestPanelSource{
  @Override
  public Panel getTestPanel(String panelId) {
    return panelToTest;
  }
}

@Test
public void testRenderSomePanel(){
    panelToTest = new SomePanel("panel");
    tester.startPanel(new SomePanelSource());
    tester.assertLabel("panel:name", <expectedName>);
}

In 1.5(.1) this changed to:

@Test
public void testRenderSomePanel(){
    tester.startComponentInPage(new SomePanel("panel"));
    tester.assertLabel("name", <expectedName>);
}

So no "panel:name" stuff anymore, simply "name": like it, updated all our
Panel-tests.
Now, in 1.5.2, I seem to have to add this panel: stuff again?

I found https://issues.apache.org/jira/browse/WICKET-4112 which lead me to
think this should not be an issue.
And, in fact one could say that
https://issues.apache.org/jira/browse/WICKET-1214 is not really fixed?

Will not upgrade to 1.5.2 for now, but I do hope this will be fixed(again).
I cannot use WicketTester.startPanel(final Class<C> panelClass) since all my
Panels have non-default constructors.

Or am I missing something?

Re: WicketTester.startComponentInPage changed again in 1.5.2?

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Tue, Oct 25, 2011 at 3:01 PM, Stijn Niclaes <st...@gmail.com> wrote:
> Last week I updated our project to 1.5.1. Did not encounter big problems,
> but did have quite a bit of deleting to do in unit tests for Panels:
> In 1.4.15 I tested my panels using implementations of TestPanelSource.
>
> class SomePanelSource implements TestPanelSource{
>  @Override
>  public Panel getTestPanel(String panelId) {
>    return panelToTest;
>  }
> }
>
> @Test
> public void testRenderSomePanel(){
>    panelToTest = new SomePanel("panel");
>    tester.startPanel(new SomePanelSource());
>    tester.assertLabel("panel:name", <expectedName>);
> }
>
> In 1.5(.1) this changed to:
>
> @Test
> public void testRenderSomePanel(){
>    tester.startComponentInPage(new SomePanel("panel"));
>    tester.assertLabel("name", <expectedName>);
> }
>
> So no "panel:name" stuff anymore, simply "name": like it, updated all our
> Panel-tests.
> Now, in 1.5.2, I seem to have to add this panel: stuff again?
>
> I found https://issues.apache.org/jira/browse/WICKET-4112 which lead me to
> think this should not be an issue.
> And, in fact one could say that
> https://issues.apache.org/jira/browse/WICKET-1214 is not really fixed?
>
> Will not upgrade to 1.5.2 for now, but I do hope this will be fixed(again).
> I cannot use WicketTester.startPanel(final Class<C> panelClass) since all my
> Panels have non-default constructors.
>
> Or am I missing something?

It seems I'm the one who causes you all these troubles ;-)

I hope the current state wont change any time soon.
The idea is that you (the developer) should provide all the component
ids that you specified in your components.
In your example you specify the id of the panel and of the label, so
you should assert with: panelId:labelId.

In the case when you use #startComponentInPage(StartedComponent.class)
you don't provide explicitly the component id so you should not care
to provide it in the assert methods as well. In this case you should
provide the ids of the inner components, e.g.
assertVisible("aComponentInsideStartedComponentId:subId")

I hope it makes sense but if you have better idea than we may
reconsider it once again.

-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org