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?
I'm using Scala, but this is a rough translation of the panel.
public class AccountListPanel extends Panel {
private IDataProvider _provider;
public AccountListPanel(String id, IDataProvider provider) {
super(id);
_provider = provider;
add(new DataView("list", provider) {
public void populateItem(Item[Account] item) {
Account account = item.getModelObject();
item.add(new Label("name", account.getName().toString()));
}
}
}
}
On Thu, Feb 5, 2009 at 5:47 PM, Timo Rantalaiho <[email protected]>wrote:
> On Thu, 05 Feb 2009, Erick Fleming wrote:
> > Looking for samples or advice for unit testing DataViews. I've been
> using
> > ListViews, since they are easy to test.
>
> What exactly do you want to test? That the data rendered
> is displayed correctly?
>
> Can you show some example code that you'd like to test?
>
> There shouldn't be anything special about it, you should
> abstract out how the dataview gets it data, for example by
> using dependency injection, and provide the data in the
> test.
>
> Best wishes,
> Timo
>
> --
> Timo Rantalaiho
> Reaktor Innovations Oy <URL: http://www.ri.fi/ >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>