Skip to main content

Execution Reporter

The dev.specbinder:execution-reporter module auto-registers a JUnit Platform TestExecutionListener and writes one JSON file per feature to the project's build output directory. Useful for CI dashboards, custom reporting, or any tooling that needs structured spec-execution data.

Source: examples/reporter/example-1 on GitHub.

What this demonstrates

  • Adding the reporter is a single test-scope dependency — no other wiring required
  • Each feature gets its own JSON report under target/specbinder-reports/...
  • The report mirrors the Gherkin hierarchy: feature → rules → scenarios → outlines → examples
  • Pass / fail / aborted statuses for every node, with full error blocks for failures
  • Non-SpecBinder tests are silently ignored

Activation

Add the dependency:

<dependency>
<groupId>dev.specbinder</groupId>
<artifactId>execution-reporter</artifactId>
<version>2026.38.0</version>
<scope>test</scope>
</dependency>

The listener registers itself via META-INF/services/org.junit.platform.launcher.TestExecutionListener and fires automatically for every test class that carries (or inherits) the @SourceFilePath marker the annotation processor adds to its generated test classes.

Running it

cd examples/reporter/example-1
mvn test

After the run, look at:

target/specbinder-reports/specs/ShoppingCart.feature.json

Report schema

The schema is hierarchical and uses the same displayName field name at every node:

feature
├── scenarios[] ← plain scenarios + Scenario Outlines under the feature
└── rules[]
└── scenarios[] ← scenarios that live under a Rule

The example feature deliberately exercises every code path the listener handles:

  • Several plain scenarios that pass (real assertions against an in-memory cart)
  • One scenario with a wrong expected total → status: "failed", populated error block
  • One scenario whose Given calls Assumptions.abort(...)status: "aborted"
  • A Rule with two scenarios → routed under the report's rules[] branch
  • A Scenario Outline with three rows → a scenarioOutline node with three examples[] entries

A note on skipped status

The example does not include a skipped scenario because SpecBinder doesn't currently translate a Gherkin @disabled tag to JUnit's @Disabled. The listener's skipped-status path is covered by the reporter module's own unit tests.