[ 
https://issues.apache.org/jira/browse/WICKET-6713?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sven Meier resolved WICKET-6713.
--------------------------------
    Fix Version/s: 9.0.0-M4
                   8.7.0
       Resolution: Fixed

> BaseWicketTester does not reset componentInPage field
> -----------------------------------------------------
>
>                 Key: WICKET-6713
>                 URL: https://issues.apache.org/jira/browse/WICKET-6713
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-core
>    Affects Versions: 8.5.0
>            Reporter: Andreas Müller
>            Assignee: Sven Meier
>            Priority: Minor
>             Fix For: 8.7.0, 9.0.0-M4
>
>
> There seems to be a bug in the BaseWicketTester, if you use the method 
> {{startComponentInPage()}} with its class signature ({{Class<C>}}) instead of 
> its instance signature ({{C component}}).
> It will set the {{componentInPage}} field with the wicketId „testObject“.
> If you then start another component in Page (passing a component instance) in 
> the same WicketTester instance, all wicketPaths from 
> {{getComponentFromLastRenderedPage()}} of that second component will be 
> prefixed with „testObject:“, because  method will use the id of the 
> {{componentInPage}} field. 
> This results in false path assertions on the later component. 
> For example this test won’t succeed:
>  
> {code}@Test
> public void testRender() {
>   WicketTester tester = new WicketTester();
>  
>   tester.startComponentInPage(DummyPanel.class);
>  
>   tester.startComponentInPage(new DummyPanel(„panel“));
>   tester.assertComponent("panel", DummyPanel.class);
> }{code}
>  
> The AssertionError is stated as follows:
> {noformat}java.lang.AssertionError: path: 'testObject:panel' does not exist 
> for page: StartComponentInPage{noformat}
>  
>  
> Without the line „tester.startComponentInPage(DummyPanel.class);“ it will run 
> smoothly.
> Usually one is not starting multiple components in one test. 
> But this issue can also have effects on other tests, if they are using the 
> same WicketTester instance.
>  
> Maybe {{startComponentInPage(final C component, IMarkupFragment pageMarkup)}} 
> should reset {{componentInPage}}, if it is not called by 
> {{startComponentInPage(final Class<C> componentClass, final IMarkupFragment 
> pageMarkup)}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to