In Vaadin, an Application represents the sum of all the components organized in Windows, Layouts and having a theme applied.

The central class representing an application is thecom.vaadin.Application class.
His responsibilities include the following:

  • Managing windows
  • Callbacks during the lifecycle of the application
  • Setting themes

It is the main servlet of your application, where all the different screen will be call. The method init(), will start the application.

On our groovy class, we need first  launch the future application, lets call it the VaadinCalculatorand add the two spock methods setup() and cleanup().

And now create the VaadinCalculator


Now, let write our first test case

Spoke framework, give you the possibility to write test in the format of given, when and then, to give you more visibility on what you write.

Line 15: I create a clickButton methods to simplify the test case on non necessary duplicate statements.
Line 22: we are interested only to know if the user click on specific button, we have the result so we need just call the Button.ClickListener.buttonClick and then check at line 12 if the result is correctly computed
Line 12: I could use the Assertions.assertThat() from fest-assert, but the one implemented inside Spock is quite better.
We need now just implement the methods signature and set a result default value to “6” on line 6 and now run the test, it should be a green line, so we can push our first version to our CMS

Now we are ready to implement our first story