Skip to content

lsd-consulting/lsd-cucumber

Repository files navigation

lsd-cucumber

CI Nightly Build GitHub release Maven Central

Cucumber plugin for lsd-core - automatically generates living sequence diagrams from your Cucumber scenarios.

Quick Start

Installation

Add the dependency to your project:

Maven
<dependency>
    <groupId>io.github.lsd-consulting</groupId>
    <artifactId>lsd-cucumber</artifactId>
    <version>X.X.X</version>
    <scope>test</scope>
</dependency>
Gradle
testImplementation 'io.github.lsd-consulting:lsd-cucumber:X.X.X'

Usage

Add the LsdCucumberPlugin to your Cucumber configuration:

Kotlin Example
@CucumberOptions(
    plugin = ["io.lsdconsulting.lsd.cucumber.LsdCucumberPlugin"],
    features = ["classpath:features"],
    glue = ["your.step.definitions"]
)
class RunCucumberTest
Java Example
@CucumberOptions(
    plugin = {"io.lsdconsulting.lsd.cucumber.LsdCucumberPlugin"},
    features = "classpath:features",
    glue = "your.step.definitions"
)
public class RunCucumberTest {
}

The plugin:

  • Hooks into Cucumber lifecycle to generate reports
  • Creates a new scenario for each Cucumber scenario
  • Generates sequence diagrams showing captured interactions
  • Marks scenarios as passed/failed based on scenario results
  • Outputs reports to build/reports/lsd/ (configurable via lsd.core.report.outputDir)

Working with lsd-core directly

You can capture events manually within step definitions:

Kotlin Example
class OrderSteps {
    private val lsd = LsdContext.instance
    
    @When("the customer places an order")
    fun customerPlacesOrder() {
        lsd.capture(
            ("Customer" messages "OrderService") { label("POST /orders") }
        )
        // Your step implementation
    }
    
    @Then("the order is confirmed")
    fun orderIsConfirmed() {
        // Your assertions
        lsd.capture(
            ("OrderService" respondsTo "Customer") { label("201 Created") }
        )
    }
}
Java Example
public class OrderSteps {
    private final LsdContext lsd = LsdContext.getInstance();
    
    @When("the customer places an order")
    public void customerPlacesOrder() {
        lsd.capture(
            messageBuilder()
                .from("Customer")
                .to("OrderService")
                .label("POST /orders")
                .build()
        );
        // Your step implementation
    }
    
    @Then("the order is confirmed")
    public void orderIsConfirmed() {
        // Your assertions
        lsd.capture(
            messageBuilder()
                .from("OrderService")
                .to("Customer")
                .label("201 Created")
                .type(SYNCHRONOUS_RESPONSE)
                .build()
        );
    }
}

See lsd-core documentation for full API details.

Example Project

For a complete working example, see lsd-kotlin-cucumber-example.

Configuration

Configure via lsd.properties on your classpath. See lsd-core configuration for available properties.

Ecosystem

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors