How to use

In your pom.xml, add the dependency and the repository:

<project ...>

To allow injecting mock objects in place of Guice beans, you need to install a special injector which wraps around your Guice injector:

public class MyApp extends WebApplication {
        protected void init() {
                                new GuiceComponentInjector(this, new MyModule()));

The rest of all is almost the same as what you should do in using Spring, except for using MockableGuiceBeanInjector for mocking. Let's implement the Page1 example by using Guice again:

        <form wicket:id="form">
                <input type="text" wicket:id="input">
                <input type="submit" value="OK">
        Result: <span wicket:id="result" id="result">abc</span>.

public class Page1 extends WebPage {
        private MyService service;
        private String input;
        private String result;

        public Page1() {
                input = service.getDefaultInput();
                Form<Page1> form = new Form<Page1>("form",
                                new CompoundPropertyModel<Page1>(this)) {
                        protected void onSubmit() {
                                result = service.getResult(input);
                form.add(new TextField<String>("input"));
                add(new Label("result", new PropertyModel<String>(this, "result")));

public interface MyService {
        String getDefaultInput();
        String getResult(String input);

Create a TestNG test class and use MockableGuiceBeanInjector for mocking

public class Page1Test {
        public void testSubmitForm() {
                MockableGuiceBeanInjector.mockBean("service", new MyService() {

                        public String getDefaultInput() {
                                return "xyz";

                        public String getResult(String input) {
                                return input + input;

                DefaultSelenium selenium = WebPageTestContext.getSelenium();
                WicketSelenium ws = new WicketSelenium(selenium);
                assert selenium.getValue("input").equals("xyz");
                assert selenium.getText("result").equals("xyzxyz");

Any more? That's all.