3

I have upgraded gwt version to 2.8 and java 1.8. Test is running fine with gwt 2.7 and java 1.7. Do I need to add extra configurations in gwt.xml or any dependency in pom

pom :

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <scope>2.8</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <scope>2.8</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <scope>2.8</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava-gwt</artifactId>
            <version>20.0</version>
        </dependency>

Test code :

public class Test extends GWTTestCase {

    Logger logger = Logger.getLogger(this.getClass().getCanonicalName());

    /* (non-Javadoc)
     * @see com.google.gwt.junit.client.GWTTestCase#getModuleName()
     */
    @Override
    public String getModuleName() {
        return "org.field.TestJUnit";
    }

    public void testRenderAndBindTopScene() {
        GWT.log("hi");
        PageEx pageEx = GWT.create(PageEx.class);
    }
}

TestJUnit.gwt.xml :

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to="Field">
    <!-- Inherit our applications main module. -->
    <inherits name='org.field.Field' />


    <source path="client" />
    <source path="shared" />

</module>

3 Answers3

3

Starting with GWT 2.8, the classic dev mode is now (officially) deprecated, and tests run in prod mode by default (i.e. compiled to JavaScript).

This means you cannot set breakpoints in your Java code and expect to be reached in a Java debugger (because they are regular JUnit 3 tests, driven by the standard JUnit runner, some of the methods will actually be called, but not the test methods themselves).
You can (temporarily) re-enable dev mode for tests by passing -devMode in the -Dgwt.args= system property, as hinted in the release notes.

Alternatively, you can run the tests in "manual" mode (you'll be given a URL to open in your browser, where you can debug the JavaScript), or you could pass the -Dgwt.htmlunit.debug system property when running tests with the HtmlUnit run style (the default) to show a debugger window (note: I have no idea how to use it).

…or "debug" the "good old way" by logging things; and/or making a small repro-case as a GWT app that you can run in your browser.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
  • Hi, I have tried using the second approach, added a argument as ${system:-devMode} in eclipse debug configurations. It didnt worked – komal_sonigra Mar 31 '17 at 13:17
  • 2
    It's `-Dgwt.args="-devMode"` (see release notes) in "JVM arguments" (can't remember the exact wording). But Eclipse debug configurations put things into gwt.args by default (-war, -logLevel) and an explicit gwt.args will override them. With a bit of luck there's actually a check box to turn devmode on or off. – Thomas Broyer Mar 31 '17 at 18:38
  • @ThomasBroyer where do you exactly specify this flag ? When I right click on a gwt test case I only see debug as -> GWT JUnit test and it doesn't allow any configuration at all. – Gautam Aug 11 '17 at 07:04
3

To enable dev-mode for debugging test case in GWT 2.8 for eclipse IDE follow below steps which will definitely help you :

  1. Right click on project in which test case is written .
  2. select debug as configuration .
  3. left side in navigation select test case which you want to debug .
  4. then select argument tab and add -Dgwt.args="-devMode" argument in box specified for VM argument.
  5. here is the screen-shot
1

This is meant as a comment on Thomas Broyer answer.

To run tests in "manual" mode you have to specify the runSytle and preferebly change the style to PRETTY.

-Dgwt.args="-runStyle Manual:1 -style PRETTY"

Eclipse JUnit VM settings example

Sašo5
  • 61
  • 1
  • 6