Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Cucumber support for the JVM: Java, Scala, Groovy, Clojure, Ioke, Javascript, Spring, Guice, PicoContainer, WebDriver, Ant and Maven
Java Scala Ruby Groovy Other

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples/simple
lib/cucumber
src/main
.gitignore
History.txt
Manifest.txt
README.textile
README.txt
Rakefile
Rakefile.old
cucumber-support.iml
pom.xml

README.textile

Have a Cuke, Duke

Cucumber runs on Java! This gem lets you write Cucumber steps in pure Java. Example:

package simple;

import java.util.Map;
import java.util.HashMap;
import cucumber.*;
import static org.junit.Assert.assertEquals;

public class StuffSteps {
    private final Map<String,String> cukes = new HashMap<String,String>();

    @Given("I have (\\d+) (.*) cukes")
    public void iHaveNCukes(String n, String color) {
        this.cukes.put(color, n);
    }

    @When("I add a table")
    public void iAddATable(Table table) {
        Map<String,String> hash = table.hashes().get(0);
        assertEquals("1", hash.get("a"));
        assertEquals("2", hash.get("b"));
    }

    @Then("I should have (\\d+) (.*) cukes")
    public void iShouldHaveNCukes(String n, String color) {
        if(!n.equals(cukes.get(color))) {
            throw new RuntimeException("Expected " + n + ", got " + cukes.get(color));
        }
    }

    public void thisIsNotAStep() {}
}

Check out the examples for more details.

Building the cucumber-java gem

This is for hackers. If you just want to use Cucumber with Java, head straight to
the examples.

Install Maven

You can grab it here

Install JRuby

You can grab it here
Make sure you get 1.2.0 or later.

Install Hoe

This gem is needed to build the Cucumber Java gem

jruby -S gem install hoe --no-rdoc --no-ri

Build and install the gem

jruby -S rake gem
jruby -S gem install pkg/cucumber-java --no-rdoc --no-ri

Now head to the simple example and run it. It serves well as a testbed.

Something went wrong with that request. Please try again.