Creating Groovy Test Case in Maven Projects

| Keine Kommentare | Keine TrackBacks
In most of my projects I'm using maven as my prefered build tool. The tool is pretty mature and if you're build process doesn't change that often it ist ok. If you need a more flexible build process, ant or gradle may be the tools of your choice.
Maven ist out the box great when doing "pure" java projects. But personally I like groovy cause some things are really nice and done with much less coding and I compiles to java byte code. So even when my customer says we just want java code and could write some groovy code.
 I n praxis I'm using groovy to write some Test Cases. The multiline string feature is a great advantage if you want to test some parsing or text generating code. When including the Groovy Eclipse plugin this works in my IDE but not in out maven build process, so I need some more steps:
  1. I've got to put my groovy code in a directory src/test/groovy (Convention over configuration) or src/main/groovy
  2. I've got to add the gmaven plugin in my build process
  3. I need to provide a groovy runtime for my testcases
Here ist an example of my pom.xml:
      <plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <version>1.3</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
...
    <dependency>
      <groupId>org.codehaus.gmaven.runtime</groupId>
      <artifactId>gmaven-runtime-1.7</artifactId>
      <version>1.3</version>
      <exclusions>
        <exclusion>
          <groupId>org.sonatype.gossip</groupId>
          <artifactId>gossip</artifactId>
        </exclusion>
      </exclusions>
      <scope>test</scope>
    </dependency>

Keine TrackBacks

TrackBack-URL: http://www.joergherbst.de/mt-tb.cgi/87

Jetzt kommentieren

Über diese Seite

Diese Seite enthält einen einen einzelnen Eintrag von joerg vom 10.10.11 8:10.

Something complete different - Posting in english ist der vorherige Eintrag in diesem Blog.

Aktuelle Einträge finden Sie auf der Startseite, alle Einträge in den Archiven.