Added "feature", "background" and "scenario" keywords

This commit is contained in:
Steven Joseph 2025-01-28 14:43:01 +11:00
parent f847e414db
commit 5c8fd0fe91
No known key found for this signature in database
GPG Key ID: 982E27B3BDB107AA

36
800.md
View File

@ -20,6 +20,7 @@ The need for BDD payloads arises from the desire to integrate automated testing
##### 1. **Event Structure**
A BDD payload is a specialized Nostr event (`kind` value: `800`). The payload must conform to the following structure:
```json
```json
{
"id": "<event_id>",
@ -28,14 +29,24 @@ A BDD payload is a specialized Nostr event (`kind` value: `800`). The payload mu
"kind": 800,
"tags": [
["test-suite", "<suite_name>"],
["test-feature", "<feature_name>"],
["test-scenario", "<scenario_name>"],
["test-description", "<description>"],
["expected-result", "<expected_result>"]
],
"content": {
"given": "<given_clause>",
"when": "<when_clause>",
"then": "<then_clause>"
"feature": "<feature_description>",
"background": {
"given": "<background_given_clause>"
},
"scenario": {
"name": "<scenario_name>",
"steps": [
{"given": "<given_clause>"},
{"when": "<when_clause>"},
{"then": "<then_clause>"}
]
}
},
"sig": "<signature>"
}
@ -46,25 +57,28 @@ A BDD payload is a specialized Nostr event (`kind` value: `800`). The payload mu
##### 2. **Tags**
- **`test-suite`**: The name of the test suite.
- **`test-scenario`**: A specific scenario name within the test suite.
- **`test-feature`**: The name of the feature being tested.
- **`test-scenario`**: A specific scenario name within the feature.
- **`test-description`**: A detailed description of the test case.
- **`expected-result`**: The expected outcome for validation.
---
##### 3. **BDD Payload Content**
The `content` field must contain the BDD clauses:
- **`given`**: The initial context or state.
- **`when`**: The action or trigger.
- **`then`**: The expected outcome or result.
The `content` field must include the following keywords:
- **`feature`**: A high-level description of the feature under test.
- **`background`**: Contains shared setup steps or context that applies to multiple scenarios (uses the **`given`** keyword).
- **`scenario`**: Describes a specific scenario to be tested. It includes:
- **`name`**: The name of the scenario.
- **`steps`**: A list of BDD steps using the **`given`**, **`when`**, and **`then`** keywords.
---
##### 4. **Relay Execution**
Relays supporting NIP-800 must:
1. Validate the event structure and signature.
2. Parse the `content` to extract the BDD clauses.
3. Execute the BDD test using a sandboxed runtime environment.
2. Parse the `content` to extract the BDD elements: **feature**, **background**, and **scenario**.
3. Execute the BDD test using a sandboxed runtime environment, applying the `background` steps before running the `scenario` steps.
4. Return the results as a new Nostr event (`kind: 801`).
---
@ -80,6 +94,7 @@ The results of a BDD test are published as a new event (`kind: 801`) by the rela
"kind": 801,
"tags": [
["test-suite", "<suite_name>"],
["test-feature", "<feature_name>"],
["test-scenario", "<scenario_name>"],
["status", "<pass|fail>"],
["error", "<error_message_if_any>"]
@ -118,4 +133,3 @@ The results of a BDD test are published as a new event (`kind: 801`) by the rela
- Support for additional test formats (e.g., unit tests).
- Integration with popular test frameworks.
- Mechanisms for incentivizing relays to execute tests (e.g., Lightning payments).