110 lines
2.3 KiB
Markdown
110 lines
2.3 KiB
Markdown
# BDD — Behavior Driven Development
|
|
|
|
## Índice
|
|
|
|
- [Overview](#overview)
|
|
- [Features](#features)
|
|
- [Step Definitions](#step-definitions)
|
|
|
|
---
|
|
|
|
## Overview
|
|
|
|
Este directorio contiene las especificaciones BDD fuente en formato Gherkin.
|
|
|
|
Separación recomendada:
|
|
- `spec/bdd/features/` = source-of-truth de escenarios
|
|
- `features/` = assets ejecutables del runner (steps, config)
|
|
|
|
### naming conventions
|
|
|
|
```text
|
|
spec/bdd/features/
|
|
├── <domain>/
|
|
│ ├── <feature-name>.feature
|
|
│ └── <feature-name>.feature
|
|
└── common/
|
|
└── <common-feature>.feature
|
|
```
|
|
|
|
### tags permitidos
|
|
|
|
| Tag | Uso |
|
|
|-----|-----|
|
|
| `@F-XXX` | Link a feature del backlog |
|
|
| `@smoke` | Tests críticos (siempre ejecutar) |
|
|
| `@regression` | Tests de regresión |
|
|
| `@integration` | Tests de integración |
|
|
| `@e2e` | End-to-end tests |
|
|
| `@unit` | Tests unitarios |
|
|
| `@api` | Tests de API |
|
|
| `@ui` | Tests de interfaz |
|
|
|
|
---
|
|
|
|
## Features
|
|
|
|
Ver `spec/bdd/features/` para los archivos `.feature`.
|
|
|
|
---
|
|
|
|
## Step Definitions
|
|
|
|
Los step definitions deben estar en:
|
|
- Python: `features/steps/*.py`
|
|
- JS/TS: `features/step_definitions/*.ts`
|
|
- Go: `features/steps/*.go`
|
|
|
|
### Template (Python/Behave)
|
|
|
|
```python
|
|
"""Steps para login feature."""
|
|
from behave import given, when, then
|
|
|
|
@given('un usuario registrado con email "{email}" y password "{password}"')
|
|
def step_registered_user(context, email, password):
|
|
"""Crea usuario de prueba."""
|
|
pass
|
|
|
|
@when('el usuario ingresa su email "{email}"')
|
|
def step_enter_email(context, email):
|
|
"""Ingresa email en el formulario."""
|
|
pass
|
|
|
|
@when('ingresa password "{password}"')
|
|
def step_enter_password(context, password):
|
|
"""Ingresa password."""
|
|
pass
|
|
|
|
@then('el sistema muestra mensaje de error "{message}"')
|
|
def step_show_error(context, message):
|
|
"""Verifica mensaje de error."""
|
|
pass
|
|
```
|
|
|
|
---
|
|
|
|
## Ejecutar Tests
|
|
|
|
### Python (Behave)
|
|
```bash
|
|
behave features/
|
|
behave features/ --tags @smoke
|
|
behave features/ --tags ~@slow # exclude
|
|
```
|
|
|
|
### Node.js (Cucumber)
|
|
```bash
|
|
npx cucumber-js features/
|
|
npx cucumber-js features/ --tags "@smoke and @F-001"
|
|
```
|
|
|
|
---
|
|
|
|
## Checklist de Feature
|
|
|
|
- [ ] Feature documentado en Gherkin
|
|
- [ ] Todos los scenarios tienen Given/When/Then
|
|
- [ ] Tags `@F-XXX` presentes
|
|
- [ ] Step definitions implementados
|
|
- [ ] Tests ejecutables |