Cool tests in the Java Maven platform now possible with rspec-maven-plugin

BDD, Java, Maven, RSpec, TDD — Tags: , , , , , — dc.rec1 @ 2:19 pm

I don’t like Maven at all but sometimes depending of the project and the people you need to use this. After playing with RSpec I stop considering any Java language framework acceptable for testing so for this project I’m working on right now I needed to find a solution that could integrate RSpec with Maven.

After googling I found this post from Bob McWhirter where he presented a official rspec-maven-plugin. I tried to use it but it wasn’t working so I forked it, fixed it and changed some things.

The forked version of rspec-maven-plugin is at GitHub and to use it you should:

install the plugin in the local repository (this is necessary only one time):

git clone git://github.com/dcrec1/rspec-maven-plugin.git
cd rspec-maven-plugin
mvn install

configure your project’s pom.xml adding this:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>rspec-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>test</id>
            <phase>test</phase>
            <goals>
                <goal>spec</goal>
            </goals>
        </execution>
    </executions>
</plugin>

set the JRUBY_HOME system variable, for example:

export JRUBY_HOME=/opt/jruby-1.1.6/

The plugin will run in the test phase of the Maven build cycle.

Happy testing!

7 Comments »

  1. Great article very important information i found here R46aRLGEzsyDQN

    Comment by 96R8EN2e — May 31, 2010 @ 9:18 pm
  2. Excellent job once again! Thanks:)

    Comment by pakaian wanita — July 31, 2011 @ 11:40 am
  3. Excellent story it is without doubt. My girlfriend has been searching for this info.

    Comment by moe Nawaz Business Coach — August 6, 2011 @ 11:37 pm
  4. [...] We could integrate it with our CI. [...]

  5. Great info it is actually. My girlfriend has been awaiting for this information.

    Comment by Santa Barbara coupons — September 1, 2011 @ 10:42 pm
  6. Really good blog you’ve got here. You’ll discover me browsing your stuff often. Saved as a favorite!

    Comment by Nicky Heiman — November 10, 2011 @ 7:20 pm
  7. Hello,

    I got following error when executing this on win 7.
    Is this pluging not supporting win os, or what could be the problem?
    Have not tried on linux.

    regards, Matti

    [INFO] — rspec-maven-plugin:1.0-beta-6:spec (test) @ vse_mppscripts —
    [INFO] Running RSpec tests from D:\subversion\vse\vse_mppscripts\test\
    [ERROR] error emitting .sh
    java.lang.NullPointerException
    at org.codehaus.mojo.rspec.ShellScriptFactory.getScript(ShellScriptFactory.java:26)
    at org.codehaus.mojo.rspec.AbstractScriptFactory.emit(AbstractScriptFactory.java:44)
    at org.codehaus.mojo.rspec.RspecRunnerMojo.execute(RspecRunnerMojo.java:120)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)

    Comment by Matti — January 16, 2012 @ 9:09 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2012 Diego Carrion | powered by WordPress with Barecity