Monday, September 18, 2017

Re: Test Strategies for Modern GWT (i.e. Elemental2 etc)

If you want to further explore the mock-based option you should check out GwtMockito: It handles natives and finals and has a few other GWT-specific features. I haven't made any big changes to it in the last couple of years, but if there are new things it could do to help with Elemental2 or other modern GWT I'm definitely open to suggestions.

Mocking helps for certain types of logic tests, but for anything that relies on logic that runs in the browser (e.g. calculating the size of elements) it doesn't get you very far, so it's not great for testing widgets. For that I don't think there's much way around WebDrive.

On Sunday, September 17, 2017 at 5:24:10 AM UTC-7, Peter Donald wrote:

Has anyone got any good examples of how they are testing GWT code that is interacting with the browser APIs. 

Historically we just ignored that low level code as we either were using pre-existing Widgets that we implicitly trusted and for that limited amount of jsni or browser interaction that we wrote we just hand tested and limited change in that area. We then built abstractions ala MVP and tested the rest of the app (which was typically 95% of the code anyhoo).

Now that we are moving to Elemental2 there are fewer abstractions and it would be nice to test the low level code. In particular small little elements. 

So how do we people do this? Options that we came up with:

* Ignore. build abstractions and use manual testing where required.
* GWTTestCase - although last time we tried it (maybe ~2010) it was nothing like a real browser and rather slow.
* Compile code and tests to javascript and figure out a way to run them in a real browser and scrape the results.
* Compile code to javascript and use webdriver/selenium to interact with browser.
* Ignore for now and wait till J2CL and use js ecosystems solutions.
* Use something like powermock to mock natives etc and run them in jre

Anyone got any examples of this working or can offer any suggestions? In particular I am interested to see examples that use Elemental2 or other jsinterop code.


Peter Donald

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment