Alexandre Cuva

Showing posts with label Spock. Show all posts
Showing posts with label Spock. Show all posts

Wednesday, February 15, 2012

Groovy Spock and Maven 3.0

Here you can found a new version of HelloSpockPom for Maven 3.0. With Maven 3.0, you don't need anymore the Spock-maven plugin. And so you can use the last artifacts like bellow
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

 <modelVersion>4.0.0</modelVersion>
 <groupId>hello</groupId>
 <artifactId>spock</artifactId>
 <version>1.0</version>
 <packaging>jar</packaging>
 <name>Hello Spock</name>

 <build>
  <plugins>
   <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>
  </plugins>
 </build>

 <dependencies>
  <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>
 </dependencies>
</project>

Thursday, February 2, 2012

Vaadin and Groovy Test 3

CalculatorSpec.groovy
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 the com.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 VaadinCalculator and add the two spock methods setup() and cleanup().

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