Warning
DEPRECATED: This library has been superseded by lsd-junit-jupiter. This repository will continue to support JUnit 5.x but new projects should use lsd-junit-jupiter for JUnit Jupiter (6.x+) support.
JUnit 5 extension for lsd-core - automatically generates living sequence diagrams from your tests.
Add the dependency to your project:
Maven
<dependency>
<groupId>io.github.lsd-consulting</groupId>
<artifactId>lsd-junit5</artifactId>
<version>X.X.X</version>
<scope>test</scope>
</dependency>Gradle
testImplementation 'io.github.lsd-consulting:lsd-junit5:X.X.X'Add @ExtendWith(LsdExtension.class) to your test class:
Kotlin Example
@ExtendWith(LsdExtension::class)
class PaymentServiceTest {
...
}Java Example
@ExtendWith(LsdExtension.class)
class PaymentServiceTest {
...
}The extension:
- Hooks into JUnit 5 lifecycle to generate reports
- Creates a new scenario for each
@Testmethod - Generates sequence diagrams showing captured interactions
- Marks scenarios as passed/failed based on test results
- Outputs reports to
build/reports/lsd/(configurable vialsd.core.report.outputDir)
You can capture events manually within tests:
Kotlin Example
@ExtendWith(LsdExtension::class)
class OrderProcessingTest {
private val lsd = LsdContext.instance
@Test
fun `should process order`() {
// Manually capture interactions
lsd.capture(
("Customer" messages "OrderService") { label("POST /orders") }
)
// Your test assertions
lsd.capture(
("OrderService" respondsTo "Customer") { label("201 Created") }
)
}
}Java Example
@ExtendWith(LsdExtension.class)
class OrderProcessingTest {
private final LsdContext lsd = LsdContext.getInstance();
@Test
void shouldProcessOrder() {
// Manually capture interactions
lsd.capture(
messageBuilder()
.from("Customer")
.to("OrderService")
.label("POST /orders")
.build()
);
// Your test assertions
lsd.capture(
messageBuilder()
.from("OrderService")
.to("Customer")
.label("201 Created")
.type(SYNCHRONOUS_RESPONSE)
.build()
);
}
}See lsd-core documentation for full API details.
Configure via lsd.properties on your classpath. See lsd-core configuration for core properties.
| Property | Default | Description |
|---|---|---|
lsd.junit5.hideStacktrace |
false |
Hide stacktraces in report popups for aborted/failed tests. Useful for approval testing where stack trace line numbers vary between builds. |
- lsd-core - Core library for generating living sequence diagrams
- lsd-interceptors - HTTP/messaging interceptors for automatic capture
- lsd-cucumber - Cucumber plugin for LSD reports