Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unit test a custom Wicket component

Given this really simple Wicket component:

public class ProductImage extends WebComponent {

    public ProductImage(String id, Product p) {
        super(id, new Model(p));
        add(new AttributeModifier("src", true, new Model(p.getImage())));
    }
}

How to unit test it using WicketTester? Do I need a page?

like image 839
Eduardo Costa Avatar asked Jan 19 '23 06:01

Eduardo Costa


1 Answers

In Wicket 1.5 there is #startComponentInPage(Component) which will create a page for you so you can test any kind of component.

like image 76
martin-g Avatar answered Jan 21 '23 20:01

martin-g