On Thu, 05 Feb 2009, Erick Fleming wrote:
> I'm new to unit testing and just trying to get my feet wet.  The actual code
> under test would be a panel that should display some data.  I guess I don't
> really care to test wicket's dataview but whether or not my panel is
> actually displaying the data.  Should I mock the IDataProvider and verify
> that certain methods are called?

Yes, and that their data is fed correctly to the items.

> I'm using Scala, but this is a rough translation of the panel.

Thanks, we all should learn Scala anyway so feel free to 
post in it ;)

>     public AccountListPanel(String id, IDataProvider provider) {

Pass in a mock IDataProvider there, and then see that the 
accounts that the mock returns get listed on the page.

for (Account account : accountsSuppliedByMockDataProvider) {
    assertEquals(account, findItemOf(account).getModelObject());
    assertEquals(account.getName(), 
findNameLabelOf(account).getModelObjectAsString());
}

Or something like that.

If your repeater initialises lazily, you sometimes have to 
call .renderComponent() on it on the test so that its 
children get created. But if it already gets its data on 
when it's first constructed and "started" by WicketTester, it 
should be rendered and the Items should be there.

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

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

Reply via email to