Alexandre Cuva

Thursday, February 2, 2012

Vaadin and Groovy Test 2

Yesterday we created our first Vaadin application with Maven. Today as a true Agile Developer we will try to work with Vaadin with our testing tools.

Work on Acceptance Test
We will work on a simple calculator, with 9 buttons for the digits, 4 buttons for the operator (/, *, -, +) and an enter button, to display the result.
The first stories would be :

  • As a User, when I push the button 2, +, 4, I expect have a result of 6
  • As a User, I expect to see a classic calculator with the numbers in a grid of 3 x 3

Prepare Maven for the Test
We use Spock, a testing and specification framework for Java and Groovy applications. And a few other testing libraries that I like to work with.


<dependency>
 <groupId>org.easytesting</groupId>
    <artifactId>fest-assert</artifactId>
    <version>1.4</version>
    <scope>test</scope>
</dependency>
<dependency>
 <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
    <scope>test</scope>
</dependency>
<dependency>
 <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>1.9.0</version>
    <scope>test</scope>
</dependency>
<dependency>
 <groupId>org.spockframework</groupId>
    <artifactId>spock-core</artifactId>
    <version>0.5-groovy-1.8</version>
    <scope>test</scope>
    <exclusions>
  <exclusion>
   <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
 <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>1.8.5</version>
</dependency>

We need also add the following plugins, so all work fine :

   <plugin>
    <groupId>org.codehaus.gmaven</groupId>
    <artifactId>gmaven-plugin</artifactId>
    <version>1.3</version>
    <configuration>
     <providerSelection>1.8</providerSelection>
     <source/>
    </configuration>
    <executions>
     <execution>
      <goals>
       <goal>testCompile</goal>
       <goal>compile</goal>
      </goals>
     </execution>
    </executions>
    <dependencies>
     <dependency>
      <groupId>org.codehaus.gmaven.runtime</groupId>
      <artifactId>gmaven-runtime-1.8</artifactId>
      <version>1.4</version>
      <exclusions>
       <exclusion>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
       </exclusion>
      </exclusions>
     </dependency>
     <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>1.8.5</version>
     </dependency>
    </dependencies>
   </plugin>


We are finally ready to start our application.

No comments:

Post a Comment