title: Testing Wicket panels with constructor arguments
body: <p>I got a page with several panels that takes several parameters in their constructors. 
  One of them being a menu that takes a list for the different buttons in the menu.</p>
  
  <p>I've tried to test it as <a href="https://stackoverflow.com/questions/6651539/how-to-unit-test-a-custom-wicket-component">components</a> but get a null pointer exception. <a href="https://stackoverflow.com/questions/2221417/wicket-testing-startpanelpanel-and-pageparameters-how-to-set-them">Using a dummy page</a> and creating the panel on the dummy page works.
  I'm not entirely happy with this approach since it introduces a lot of new code in my tests and more possibilities for errors. </p>
  
  <p>Is there a better way of testing panels that takes arguments in their constructor?</p>
  
  <hr>
  
  <p>Sure thing:
  The code that gives an null pointer error:</p>
  
  <pre><code>public void testVisitPanel(){
      VisitPanel v = new VisitPanel("visitPanel");
      tester.startComponent(v);
      tester.assertContains("DATE");
  }
  </code></pre>
  
  <p>The panel</p>
  
  <pre><code>public VisitPanel(String id) {
      super(id);
      add( new Label("visitDate", "DATE"));
      add( new Label("visitStage", "VISIT SIGNED"));
  }
  </code></pre>
  
  <p>And the html</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html 
      xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:wicket="http://wicket.sourceforge.net/" 
      xml:lang="en" 
      lang="en"&gt;  
  &lt;wicket:head&gt;
  &lt;/wicket:head&gt;
  
  &lt;body&gt;
      &lt;wicket:panel&gt;
          &lt;span wicket:id="visitDate"&gt;VISIT DATE&lt;/span&gt;
          &lt;span wicket:id="visitStage"&gt;STAGE&lt;/span&gt;
      &lt;/wicket:panel&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>