Behaviour-Driven Development (BDD) with Google Web Toolkit (GWT)

Here at crealytics, we are developing a very interesting Rich Internet Application (RIA) using the Google Web Toolkit (GWT) with a REpresentational State Transfer (REST) Server. We use Behaviour-Driven Development (BDD) for outside-in development driven by business value. BDD for web apps is usually a good fit, as several testing tools support Javascript. As we do not have a specialist for GUI design yet, we have decided to use a Model-View-Presenter (MVP) pattern and start testing at the presenter level (outside) down to the server (in). This combination proves to be harder than expected as most Javascript testing tools work on the UI level by clicking on links, filling forms etc.

Right now we are using Cuke4Duke for story- or acceptance-tests to drive the overall implementation and use Scala Specs for unit testing. Both tools do not provide any means to run in a GWTTestCase and can therefore only test pure Java parts of the application. This is not too big a problem for the unit tests, as only view classes (which should be very slim using MVP) and a few classes concerning client-server connections and JSON parsing must be tested otherwise. The real problem is, that our integration tests in Cuke4Duke can not test the correctness of the entire application, especially that the  integration of  classes works. We are considering writing GWT generators which take Cuke4Duke stories and generate corresponding GWTTestCases that can test the entire stack in Javascript.

During the next months I will go into more detail on the application we develop and the technologies we use to create the maybe best software for managing SEM campaigns known to man 😉


Martin is developing a bid management solution for crealytics. He is also a long-term meditator and interested in neuro-feedback.

    Find more about me on:
  • twitter
  • Did you ever get further with BDD-ing GWT?

    Just a brief stab at using GWTTestCase within eclipse tells me it is slow (spools up HTTP server I suppose for each test?).

    Just a brief stab at running same tests from cuke4duke tells me you need a lot more effort to set up and run GWT test cases.

    We decided to write a unit test to reflect the cuke scenario, and then invoke individual given/when/then private methods that mimicked the steps. Even so, they run slow (as pointed out on GWT website).

    For integration tests, I guess maybe Selenium scripts?

    Curious if you got any further.

    Vielen Dank!

  • MMauch

    Hi Jon,

    we are basically still using the same test setup as mentioned above, except that we’re now using Mockito instead of Scala Specs (setup of Scala/GWT/Maven was a little bit heavy).
    We tried Selenium 2.0, but it was quite annoying and fragile to locate elements on the page using Xpath. So in most cases we’re testing presenter and downwards using plain old Java tests. In some circumstances that means we have to write things twice to have a Java compatible and a GWT compatible version of a class, but that’s only a small part of the code and in my opinion well worth the effort.

    Gern geschehen 🙂