MiniSpec
MiniSpec β BDD Testing Framework for Delphi
π Language: English | EspaΓ±ol
Behavior-Driven Development (BDD) framework for Delphi β Write executable specifications with fluent Gherkin-style syntax (Given/When/Then). A modern alternative to DUnit and DUnitX for test-driven development.
Keywords: Delphi testing, BDD Delphi, Gherkin Delphi, Cucumber for Delphi, unit testing, TDD, test framework, Object Pascal testing, RAD Studio testing
Why MiniSpec?
- π― Native Gherkin syntax β Given/When/Then directly in Delphi code
- π Fluent API β Natural chaining without external
.featurefiles - π§ͺ Type-safe β Autocomplete and compile-time verification
- π Multiple reporters β Console, JSON, JUnit (CI/CD), Live Dashboard
- π·οΈ Powerful filtering β By tags, features, scenarios, categories
- π Dependency injection β Lightweight built-in system
- π¦ Zero dependencies β Standalone, just copy the folder
Installation
MiniSpec is part of the DAF Project but is completely standalone. It has no dependencies on other DAF modules.
To use MiniSpec: 1. Copy the src/MiniSpec folder to your project 2. Add the folder to your Delphi search path 3. Add uses Daf.MiniSpec to your test units
Thatβs it! No additional setup required.
Quick Start
unit Calculator.Add.Feat;
interface
implementation
uses Daf.MiniSpec, Calculator.Engine;
type
TWorld = class
Calculator: TCalculator; // System Under Test
A, B, Result: Integer; // Parameters from Examples
end;
initialization
Feature('Calculator Addition @arithmetic')
.UseWorld<TWorld>
.Background
.Given('I have a calculator', procedure(W: TWorld)
begin
W.Calculator := TCalculator.Create;
end)
.ScenarioOutline('Adding <A> and <B> should be <Result>')
.Given('the numbers <A> and <B>') // Auto-bound from Examples
.When('they are added', procedure(W: TWorld)
begin
W.Calculator.Add(W.A, W.B);
end)
.&Then('the result is <Result>', procedure(W: TWorld)
begin
Expect(W.Calculator.Result).ToEqual(W.Result);
end)
.Examples(
[['A', 'B', 'Result'],
[1, 1, 2],
[10, 20, 30],
[5, -2, 3]])
end.Run:
CalculatorSpecs.exe # Run all tests
CalculatorSpecs.exe -f "@arithmetic" # Only tests tagged @arithmetic
CalculatorSpecs.exe -f "Feat:Calculator" # Filter by feature
CalculatorSpecs.exe -r live # Real-time dashboard
CalculatorSpecs.exe -r junit:output=results.xml # For CI/CDKey Features
| Feature | Description |
|---|---|
| Gherkin Vocabulary | Feature, Scenario, Given, When, Then, And, But, Background, Rule |
| Scenario Outline | Data-driven tests with Examples table |
| DataTables | Inline structured data in steps |
| Step Bindings | Reusable steps with regex attributes |
| Before/After | Feature-level hooks |
| Tags & Filters | @tag, Feat:, Scen:, Rule:, Cat: |
| Assertions | Full Expect() API with matchers |
| Test Doubles | Elegant Stub<T>, Mock<T>, SpyOn<T> API |
| Reporters | Console, JSON, JUnit, Gherkin, Live Dashboard |
Documentation
| Resource | Description |
|---|---|
| User Guide | Complete documentation of all features |
| Test Doubles | Stubs, Mocks, and Spies |
| Testing Patterns | BDD for unit, integration, and E2E tests |
| Samples | Working examples |
| Changelog | Version history |
Reporters
| Reporter | Command | Description |
|---|---|---|
| Console | -r console |
Colorful Gherkin-style terminal output (default) |
| Live | -r live:port=8080 |
Real-time interactive dashboard via SSE |
| JUnit | -r junit:output=results.xml |
CI/CD compatible (GitHub Actions, GitLab, Jenkins) |
| JSON | -r json:output=results.json |
Structured JSON output |
| Gherkin | -r gherkin |
Plain Gherkin text format |
JUnit (CI/CD)
MySpecs.exe -r junit:output=test-results.xmlCompatible with GitHub Actions, GitLab CI, Jenkins, Azure DevOps.
Multiple Reporters
MySpecs.exe -r console -r junit:output=results.xml -r json:output=report.jsonOr configure via MiniSpec.ini (created automatically on first run):
[minispec]
reporters=console,junit
[reporter.junit]
output=results.xmlSee Reporters for full details.
Requirements
- Delphi 12 Athens or later (requires multi-line strings
''') - Windows (32/64 bit)
License
Contributing
Found a bug? Have an idea? Open an issue or submit a PR.
Built with β€οΈ for the Delphi community
DAF Project β Delphi Application Framework