Skip to content

BDD::Behave

The latest version of this documentation lives at https://gdonald.github.io/BDD-Behave/.

The homepage for BDD::Behave is https://github.com/gdonald/BDD-Behave.

Synopsis

BDD::Behave is a behavior-driven development framework for Raku. Specs are ordinary Raku files that use BDD::Behave; and call exported DSL helpers (describe, context, it, let, before-each, expect, …) to build and run a tree of examples.

Currently developed against Raku v6.d.

Example Usage

specs/001-spec.raku

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
use BDD::Behave;

describe 'this spec', {
  let(:answer, { 42 });

  it 'passes', {
    expect(:answer).to.be(42);
  }
}

describe 'this final spec', {
  let(:answer, { 42 });

  it 'fails at line 15', {
    expect(:answer).to.be(41);
  }
}

Run it with the behave runner:

1
$ behave specs/001-spec.raku

Output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
⮑  'this spec'
  ⮑  'passes'
    ⮑  SUCCESS
⮑  'this final spec'
  ⮑  'fails at line 15'
    ⮑  FAILURE

Failures:

  [ ✗ ] specs/001-spec.raku:15
      Expected: 42
      to be: 41

2 examples, 1 failed, 1 passed

Install

BDD::Behave can be installed using the zef module installation tool:

1
zef install BDD::Behave