Thirty seconds to first green.
One command to install. One specs/ directory to create.
behave finds and runs every *spec.raku it sees.
#1. install with zef
Behave is distributed through Raku's package manager,
zef. Don't have Raku yet?
Grab it from rakudo.org.
zef ships with every install.
That installs the BDD::Behave module and puts the behave CLI
on your PATH. Verify:
$ behave --version
BDD::Behave 0.0.4
#2. write your first spec
Create a specs/ directory next to your lib/, and drop a
file named anything ending in spec.raku:
use BDD::Behave;
describe 'String#flip', {
it 'reverses the characters', {
expect('hello'.flip).to.be('olleh');
}
it 'is its own inverse', {
expect('hello'.flip.flip).to.be('hello');
}
}
#3. run it
Point behave at a file, a directory, or run it with no arguments. It
will automatically look for a specs/ directory and run anything
matching spec.raku.
..
2 examples, 0 failed, 2 passedThat's the progress formatter's default output. Try a different one:
⮑ 'String#flip'
⮑ 'reverses the characters'
⮑ SUCCESS
⮑ 'is its own inverse'
⮑ SUCCESS
2 examples, 0 failed, 2 passed#useful flags
| Flag | What it does |
|---|---|
| --format NAME | Pick an output formatter: tree, progress, documentation, html, json, junit, tap. |
| --tag NAME | Run only examples tagged NAME. Use ~NAME to exclude. |
| --example REGEX | Filter examples by description regex. |
| --seed N | Fix the example-order random seed for reproducible runs. |
| --fail-fast | Stop on the first failure. |
| --profile | Print the "top N slowest" report at the end. |
| --slow-threshold S | Mark any example over S seconds inline. |
| --memory-profile | Print per-example RSS deltas. Pair with --memory-threshold. |
| --coverage | Record line coverage. Pair with --coverage-dir lib. |
| --benchmark | Run benchmark blocks and print the summary. |
| --help | The full list, with descriptions. |
#continuous integration
For CI dashboards, pick a machine-readable formatter and pipe the output where your runner expects it.
- name: Run specs
run: behave --format junit specs/ > junit.xml
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: junit
path: junit.xml
# JSON for custom dashboards
behave --format json specs/ > report.json
# TAP for prove / tappy consumers
behave --format tap specs/ | tappy
# HTML report you can open locally
behave --format html specs/ > report.html && open report.html
#where to go next
Tour the syntax
describe, context, it, let, hooks, shared contexts and examples.
The matcher catalog
Every built-in matcher, plus how to write and compose your own.
Mocks, stubs & spies
Verifying doubles, partial mocks, argument matchers, auto-cleanup.
Formatters
Tree, progress, doc, HTML, JSON, JUnit XML, TAP, and how to add yours.