You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Andreas Müller (Jira)" <ji...@apache.org> on 2019/11/15 13:50:00 UTC
[jira] [Created] (WICKET-6713) BaseWicketTester does not reset
componentInPage field
Andreas Müller created WICKET-6713:
--------------------------------------
Summary: 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
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)