Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5f68e8a
add CLI
samderlust May 10, 2025
5585f5c
parse option
samderlust May 10, 2025
ba872bf
rename cli
samderlust May 10, 2025
e91205c
eject build_runner
samderlust May 10, 2025
f0e82e8
regenerate missing file
samderlust May 12, 2025
9b6f080
copywith
samderlust May 13, 2025
cfb8132
fix log
samderlust May 15, 2025
c2a3bea
update flag handling
samderlust May 15, 2025
bd4e401
add testcases
samderlust May 16, 2025
2fcd522
fix manifest builder
samderlust May 19, 2025
fa7963b
refactor manifest generating
samderlust May 20, 2025
a83e1c7
refacto phase 1
samderlust Apr 1, 2026
1c2906e
feat: add support for custom scenario class names, ignore/disable dec…
samderlust Apr 1, 2026
73b5823
feat: implement incremental test generation with manifest tracking an…
samderlust Apr 1, 2026
d0277c2
test: add unit tests for config and manifest parsers and update manif…
samderlust Apr 1, 2026
294ad8d
feat: add login feature example and improve BDD test generation archi…
samderlust Apr 1, 2026
f8d1bbc
feat: add support for custom test directories, additional imports, an…
samderlust Apr 1, 2026
bca9d09
feat: add bdd_flutter test command with automated test runner and for…
samderlust Apr 1, 2026
98bb804
refactor: remove deprecated --no-widget-test and --new-only CLI flags…
samderlust Apr 1, 2026
6452ec9
refactor: add comprehensive documentation to domain, infrastructure, …
samderlust Apr 1, 2026
b05cfec
plan mcp
samderlust Apr 1, 2026
330df52
feat: release major version 1.0.0 with standalone CLI, incremental ge…
samderlust Apr 1, 2026
6b65a7c
chore: remove obsolete flutter-rules.mdc cursor rules file
samderlust Apr 1, 2026
4aef4bc
format
samderlust Apr 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ migrate_working_dir/
.flutter-plugins
.flutter-plugins-dependencies
build/
.cursor/
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
"--delete-conflicting-outputs"
],
"cwd": "${workspaceFolder}/example"
},
{
"name": "Debug BDD CLI",
"request": "launch",
"type": "dart",
"program": "${workspaceFolder}/bin/bdd_flutter.dart",
"args": [
"build",
"--verbose",
"--delete-conflicting-outputs"
],
"cwd": "${workspaceFolder}/example"
}
]
}
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
## 1.0.0

### BREAKING CHANGES

- Removed `build_runner` dependency entirely — use `dart run bdd_flutter build` instead
- Removed `--no-widget-test` and `--new-only` CLI flags
- Configuration moved from `build.yaml` to `.bdd_flutter/config.yaml`
- Generated file extensions changed from `.bdd_scenarios.g.dart` to `.bdd_scenarios.dart` and `.bdd_test.g.dart` to `.bdd_test.dart`

### Features

- New standalone CLI: `dart run bdd_flutter build` and `dart run bdd_flutter test`
- Incremental test generation with manifest tracking (only regenerates changed scenarios)
- `--force` flag to regenerate all files
- `test` command with formatted Feature/Scenario report output
- Custom test directory via `test_dir` config option
- Custom scenario class suffix via `scenario_suffix` config option (e.g., `Steps` instead of `Scenario`)
- Additional imports support via `additional_imports` config option
- Background steps support
- `@unitTest` / `@widgetTest` decorators at feature and scenario level
- Scenario-level Examples tables for parameterized tests

### Improvements

- Clean Architecture restructure (domain, infrastructure, presentation layers)
- Instance-based scenario classes (supports `late` fields for shared state)
- Comprehensive documentation across all layers

## 0.3.0

- remove `build_runner` dependency
- add custom CLI
- `dart run bdd remane` to remove `.g` from generated files extension
- `dart run bdd build` to generate files from feature files

## 0.2.0

- change output files extension to `.bdd_scenarios.g.dart` and `.bdd_test.g.dart`
Expand Down
121 changes: 121 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## What This Project Is

bdd_flutter is a Dart CLI tool that generates Flutter/Dart test files from Gherkin `.feature` files. Users write BDD scenarios in `.feature` files, run `dart run bdd_flutter build`, and get `.bdd_scenarios.dart` (step stubs) and `.bdd_test.dart` (runnable tests) files generated alongside the feature file.

## Common Commands

```bash
# Run package tests (not example — example uses flutter_test)
dart test test/parsers/ test/builders/

# Run the CLI locally against the example project
cd example && dart run bdd_flutter build

# Run BDD tests with formatted report
cd example && dart run bdd_flutter test

# Force regenerate all
cd example && dart run bdd_flutter build --force

# Analyze code
dart analyze

# Get dependencies
dart pub get
```

## Architecture

Clean Architecture in `lib/src/`. The CLI entry point is `bin/bdd_flutter.dart`.

### Code Generation Pipeline

```
BDDCLI.run(args)
→ BDDController.generateFeatureTestCases(options)
→ ConfigParser.loadConfig() # .bdd_flutter/config.yaml
→ ManifestParser.loadManifest() # .bdd_flutter/manifest.yaml
→ FeatureParser.parseFeature(filePath) # .feature → Feature model
→ ScenariosFileBuilder.buildScenarioFile(feature) # Feature → .bdd_scenarios.dart
→ TestFileBuilder.buildTestFile(feature) # Feature → .bdd_test.dart
→ ManifestParser.saveManifest() # update manifest
```

### Layers

- **`domain/`** — Core models: Feature, Scenario, Step, Decorator, Background, BDDConfig, Manifest, BuildOptions
- **`infrastructure/parsers/`** — FeatureParser, ConfigParser, ManifestParser
- **`infrastructure/builders/`** — ScenariosFileBuilder, TestFileBuilder (domain models → Dart code)
- **`presentation/cli/`** — BDDCLI entry point, argument parsing
- **`presentation/controllers/`** — BDDController orchestrates config, manifest, parsing, building
- **`presentation/reporter/`** — BDDTestRunner (CLI `test` command), BDDReportFormatter (output formatting), BDDTestReporter (legacy, exported)

### Domain Models

- **Feature** — name, path, scenarios, decorators, optional background
- **Scenario** — name, steps, optional examples table, decorators, optional customClassName
- **Step** — keyword (Given/When/Then/And) + text with `<param>` placeholders
- **Decorator** — enum: `unitTest`, `widgetTest`
- **Background** — shared setup steps applied to all scenarios in a feature
- **BDDConfig** — generate_widget_tests, enable_reporter, ignore_features
- **Manifest** — tracks generated features, scenario hashes for incremental builds
- **BuildOptions** — CLI flags: widgetTest, reporter, force, newOnly

### Generated Code Pattern

Scenario classes use **instance methods** (not static), so users can add `late` fields for shared state between steps:

```dart
// .bdd_scenarios.dart
class IncrementScenario {
Future<void> iHaveACounter(WidgetTester tester) async { ... }
Future<void> iIncrementIt(WidgetTester tester) async { ... }
}

// .bdd_test.dart
final scenario = IncrementScenario();
await scenario.iHaveACounter(tester);
```

### Generation Modes

- **Incremental (default)** — compares scenario hashes against manifest, skips unchanged, appends new scenarios
- **Force (`--force`)** — regenerates everything

### Decorators

- `@unitTest` / `@widgetTest` — on feature or scenario (scenario overrides feature)
- Feature files only contain behavior-relevant tags; tooling config lives in `.bdd_flutter/config.yaml`

### CLI Commands

- `build` — Generate test files (incremental by default)
- `build --force` — Regenerate all files regardless of changes
- `test` — Run BDD tests with formatted Feature/Scenario report

### Config File

`.bdd_flutter/config.yaml`:
- `test_dir` (string, default `test/`) — where to scan for `.feature` files
- `generate_widget_tests` (bool, default true)
- `ignore_features` (list of paths to skip)
- `additional_imports` (list of imports added to every generated `_scenarios.dart`)
- `scenario_suffix` (string, default `Scenario`) — class name suffix (e.g., `Steps`)

### Manifest File

`.bdd_flutter/manifest.yaml` — auto-generated, tracks per-feature paths, timestamps, and scenario hashes for incremental builds.

## Coding Conventions

- Use PascalCase for classes, camelCase for variables/functions, underscore_case for files
- Always declare explicit types; avoid `dynamic`
- One export per file
- Functions should be <20 lines with a single purpose
- Prefer composition over inheritance
- Use early returns to avoid deep nesting
- Follow Arrange-Act-Assert for tests
Loading
Loading