feature¶
The Given-When-Then extension defines a single document kind: feature. A feature carries one or more scenarios about one consistency unit.
Top-Level Fields¶
| Field | Required | Description |
|---|---|---|
apiVersion |
yes | schema.esdm.io/given-when-then/v1 |
kind |
yes | feature |
name |
yes | The feature name. |
scope |
yes | The consistency unit the feature is about. The discriminator inside selects the variant. |
scenarios |
yes | Non-empty list of scenarios. See scenario. |
description |
no | Free-form prose. |
metadata |
no | Non-semantic labels and annotations. |
scope¶
The variant of the feature is determined by which discriminator field is present:
| Discriminator field | Variant | Required scope fields |
|---|---|---|
aggregate |
Aggregate | domain, boundedContext, aggregate |
dynamicConsistencyBoundary |
DCB | domain, boundedContext, dynamicConsistencyBoundary |
processManager |
Process Manager | domain, processManager (Process Managers are domain-scoped) |
readModel |
Read Model | domain, boundedContext, readModel |
The chosen variant fixes the form of every given, when, and then in the feature's scenarios. Mixing variants inside one feature is forbidden.
Example: Aggregate Variant¶
apiVersion: schema.esdm.io/given-when-then/v1
kind: feature
name: starting-a-round
scope:
domain: golf-club-management
boundedContext: round-play
aggregate: round
scenarios:
- name: a-fresh-round-starts
given: []
when:
command: start-round
data:
roundId: r-1
playerId: p-1
courseId: c-1
then:
events:
- event: round-started
data:
roundId: r-1
playerId: p-1
courseId: c-1
startedAt: 2026-04-30T10:00:00Z