[ 
https://issues.apache.org/jira/browse/WICKET-6713?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16975635#comment-16975635
 ] 

ASF subversion and git services commented on WICKET-6713:
---------------------------------------------------------

Commit cf99783fcf2a01936ea9d51bb34ab9db5fa6d6dc in wicket's branch 
refs/heads/wicket-8.x from Sven Meier
[ https://gitbox.apache.org/repos/asf?p=wicket.git;h=cf99783 ]

WICKET-6713 start via class or instance

on same tester


> 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
>
> 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