Search code examples
gwtgwtmockito

cannot debug GWT native code within gwtmockito


I have a GwtMockitoTestCase and the debugger seems not to enter inside any vanilla GWT class like Widget, ResizeLayoutPanel, etc. However, when running the same code inside DevMode, the debugger steps correctly through that code.

Does this have to do with GWT running inside a JRE? If not, could it be that my classpath is wrong somehow? Or maybe the gwt-user jar doesn't have debugging information?

I've also tried to extend a GWT class:

ResizeLayoutPanel w = new ResizeLayoutPanel() {
        @Override
        public void setWidget(Widget pW) {
            super.setWidget(pW); (1)
        }
    };

And breakpoint on line (1) is working but pressing F5, it doesn't go inside ResizeLayoutPanel's setWidget method.

Thank you!


Solution

  • After digging in the GwtMockito code, it seems there are a certain set of classes that are stubbed and some methods' body is removed. Therefore it's not possible to debug those methods.

    The question that remains is that somehow GWTMockito breaks the code coverage tool(EclEmma) which shows less code covered than it's supposed to. I've posted a separate question on this topic on SO: false code coverage reported using GwtMockito

    Some technical background:

    GwtMockitoClassLoader stubs some classes from GWT completely, please check GwtMockitoTestRunner#getClassesToStub() which includes Widget and ResizeLayoutPanel classes.

    The stubbing process removes the body completely for the methods returning primitive values or void, see GwtMockitoClassLoader#onLoad. If the return is a java bean, it will return a mocked version for it.