CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-io-cucumber--cucumber-java

Cucumber-JVM Java library providing annotation-based step definitions for Behavior-Driven Development (BDD) testing

Pending
Overview
Eval results
Files

step-definitions.mddocs/

Step Definitions

Core step definition annotations for writing BDD test steps in multiple languages. Cucumber-Java generates language-specific step definition annotations for over 70 languages, supporting both Cucumber expressions and regular expressions.

Capabilities

English Step Definitions

The most commonly used step definition annotations from the English language package.

/**
 * Step definition annotation for Given steps
 * @param value Cucumber expression or regular expression pattern
 */
@Given("step text with {parameter}")
public void givenStep() { }

/**
 * Step definition annotation for When steps  
 * @param value Cucumber expression or regular expression pattern
 */
@When("step text with {parameter}")
public void whenStep() { }

/**
 * Step definition annotation for Then steps
 * @param value Cucumber expression or regular expression pattern
 */
@Then("step text with {parameter}")
public void thenStep() { }

/**
 * Step definition annotation for And steps
 * @param value Cucumber expression or regular expression pattern
 */
@And("step text with {parameter}")
public void andStep() { }

/**
 * Step definition annotation for But steps
 * @param value Cucumber expression or regular expression pattern
 */
@But("step text with {parameter}")
public void butStep() { }

Usage Examples:

import io.cucumber.java.en.*;

public class StepDefinitions {
    
    // Cucumber expression with built-in parameter types
    @Given("I have {int} cukes in my belly")
    public void i_have_cukes_in_my_belly(int cukes) {
        // Implementation
    }
    
    // Regular expression with capture groups
    @When("^I eat (\\d+) cukes$")
    public void i_eat_cukes(int cukes) {
        // Implementation  
    }
    
    // Step with custom parameter type
    @Then("the date should be {date}")
    public void the_date_should_be(LocalDate date) {
        // Implementation using custom date parameter type
    }
    
    // Multiple annotations on same method
    @Given("I am logged in")
    @And("I have admin privileges")
    public void user_setup() {
        // Shared implementation
    }
}

Repeatable Annotations

Container annotations for multiple step definitions on a single method.

/**
 * Container for multiple @Given annotations
 */
@Given.Givens({
    @Given("first condition"),
    @Given("second condition")
})
public void multipleGivenConditions() { }

/**
 * Container for multiple @When annotations  
 */
@When.Whens({
    @When("first action"),
    @When("second action")
})
public void multipleWhenActions() { }

/**
 * Container for multiple @Then annotations
 */
@Then.Thens({
    @Then("first outcome"),
    @Then("second outcome")  
})
public void multipleThenOutcomes() { }

/**
 * Container for multiple @And annotations
 */
@And.Ands({
    @And("first additional step"),
    @And("second additional step")
})
public void multipleAndSteps() { }

/**
 * Container for multiple @But annotations
 */
@But.Buts({
    @But("first exception"),
    @But("second exception")
})
public void multipleButExceptions() { }

International Step Definitions

Cucumber-Java generates step definition annotations for 70+ languages using their native Gherkin keywords.

French (io.cucumber.java.fr):

import io.cucumber.java.fr.*;

@Soit("j'ai {int} concombres")
public void j_ai_concombres(int nombre) { }

@Quand("je mange {int} concombres") 
public void je_mange_concombres(int nombre) { }

@Alors("j'ai {int} concombres dans le ventre")
public void j_ai_concombres_dans_le_ventre(int nombre) { }

German (io.cucumber.java.de):

import io.cucumber.java.de.*;

@Angenommen("ich habe {int} Gurken")
public void ich_habe_gurken(int anzahl) { }

@Wenn("ich {int} Gurken esse")
public void ich_esse_gurken(int anzahl) { }

@Dann("habe ich {int} Gurken im Bauch")  
public void habe_ich_gurken_im_bauch(int anzahl) { }

Spanish (io.cucumber.java.es):

import io.cucumber.java.es.*;

@Dado("que tengo {int} pepinos")
public void tengo_pepinos(int cantidad) { }

@Cuando("como {int} pepinos")
public void como_pepinos(int cantidad) { }

@Entonces("tengo {int} pepinos en la barriga")
public void tengo_pepinos_en_la_barriga(int cantidad) { }

Available Language Packages

Cucumber-Java supports step definitions in the following languages:

LanguagePackageKeywords
Arabicio.cucumber.java.ar.*وبالنظر إلى، عندما، ثم
Chinese (Simplified)io.cucumber.java.zh_cn.*假如، 当, 那么
Chinese (Traditional)io.cucumber.java.zh_tw.*假設、當、那麼
Dutchio.cucumber.java.nl.*Gegeven, Als, Dan
Englishio.cucumber.java.en.*Given, When, Then
Frenchio.cucumber.java.fr.*Soit, Quand, Alors
Germanio.cucumber.java.de.*Angenommen, Wenn, Dann
Italianio.cucumber.java.it.*Dato, Quando, Allora
Japaneseio.cucumber.java.ja.*前提、もし、ならば
Koreanio.cucumber.java.ko.*조건、만일、그러면
Portugueseio.cucumber.java.pt.*Dado, Quando, Então
Russianio.cucumber.java.ru.*Дано, Когда, Тогда
Spanishio.cucumber.java.es.*Dado, Cuando, Entonces

And 50+ additional languages including Hindi, Thai, Vietnamese, Hebrew, Polish, Czech, and many others.

Parameter Types

Step definitions support various built-in parameter types and custom parameter types:

Built-in Types:

@Given("I have {int} items")        // Integer parameter
@Given("I have {float} dollars")     // Float parameter  
@Given("I have {double} percentage") // Double parameter
@Given("I have {biginteger} points") // BigInteger parameter
@Given("I have {bigdecimal} score")  // BigDecimal parameter
@Given("I have {byte} flags")        // Byte parameter
@Given("I have {short} count")       // Short parameter
@Given("I have {long} id")          // Long parameter
@Given("I have {string} name")       // String parameter (quoted)
@Given("I have {word} status")       // String parameter (single word)

Usage with Data Tables and Doc Strings:

@Given("the following users exist:")
public void users_exist(List<Map<String, String>> users) {
    // users contains list of user data from table
}

@Given("the following JSON:")
public void json_data(String docString) {
    // docString contains the raw JSON text
}

Install with Tessl CLI

npx tessl i tessl/maven-io-cucumber--cucumber-java

docs

data-handling.md

hooks.md

index.md

parameter-transformation.md

runtime-context.md

step-definitions.md

tile.json