moonrockzmoonspec
v0.11.0next

BDD test framework for MoonBit

Specs in Gherkin. Tests with moon test.

Parse .feature files, match steps with Cucumber Expressions, and run each scenario as a native moon test test. The next docs describe unreleased root sync APIs and the optional async facade.

Feature: Calculator
  Scenario: Addition
    Given a calculator
    When I add 2 and 3
    Then the result should be 5
#moonspec.when("I add {int} and {int}")
fn when_add(world : CalcWorld, a : Int, b : Int) -> Unit {
  world.result = a + b
}

Why moonspec

Native moon test

One test per scenario: filter with -f, list with --outline, skip with tags. Next adds sync tests on Wasm-GC.

Typed steps

Cucumber Expressions decoded to Int, String, DataTable or your own types.

Codegen CLI

gen steps and gen build keep tests in step with your .feature files.

Hooks & attachments

Before and after the run, each case and each step. Text, bytes and URLs.

Reports

Pretty console output, Cucumber Messages (NDJSON) and JUnit XML.

Tags, retries, dry-run

@smoke and not @slow, @retry(3), @skip.

Get started in 3 steps

# 1. Add the library
moon add moonrockz/moonspec
moon add moonbitlang/async
# 2. Install the CLI
moon install moonrockz/moonspec/cmd/moonspec
# 3. Generate and run
moonspec gen steps
moonspec gen build features/*.feature -w CalcWorld --apply
moon test --target js