Read the fast-check guide · Read the Stryker guide · Read the Cucumber guide

Inspect and run the delivery-rule examples.

Owned fictional fixture, executed locally on 15 October 2026. No customer data, AI calls or hosted Cue April execution. The seeded fault is deliberate; it is not a model benchmark.

Verified with Node 24.21.0, fast-check 4.10.2, Stryker 10.0.0 and Cucumber.js 13.3.0.

Download source and recorded results Verify file checksums

Recorded local summary

fast-check found basket 5000 with seed 20261015 and path 26. Cucumber failed exactly one of three scenarios before the fix. The boundary mutation survived two example tests and was killed after adding the exact-threshold assertion.

{
  "provenance": "Owned fictional fixture, executed locally. No AI calls, hosted Cue April run or customer data.",
  "verifiedOn": "2026-10-15",
  "node": "v24.21.0",
  "versions": {
    "fast-check": "4.10.2",
    "@stryker-mutator/core": "10.0.0",
    "@cucumber/cucumber": "13.3.0"
  },
  "property": {
    "fixture": "buggy",
    "failed": true,
    "seed": 20261015,
    "path": "26",
    "counterexample": [
      5000
    ],
    "numRuns": 27,
    "numShrinks": 0
  },
  "mutation": {
    "weak": {
      "Killed": 4,
      "Survived": 1
    },
    "strong": {
      "Killed": 5
    }
  }
}

Native reports and command outputs

Published logs normalise the local working-directory path to <example-root>. Outcomes and counts are unchanged. See README for commands, scope and expected failures.

package.json

Download this file

{
  "name": "cue-april-testing-examples",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "description": "Owned, local educational examples. No hosted Cue April execution or AI calls.",
  "engines": { "node": "24.x" },
  "scripts": {
    "test": "node --test test/strong.test.mjs",
    "test:weak": "node --test test/weak.test.mjs",
    "test:weak:bug": "node --test test/weak-bug.test.mjs",
    "test:property": "node property.mjs",
    "test:property:bug": "node property.mjs --buggy",
    "test:gherkin": "cucumber-js --import features/steps.mjs --format progress --format json:results/cucumber-fixed.json",
    "test:gherkin:bug": "cucumber-js --import features/steps.mjs --world-parameters '{\"buggy\":true}' --format progress --format json:results/cucumber-buggy.json",
    "test:mutation:weak": "stryker run stryker.weak.json",
    "test:mutation:strong": "stryker run stryker.strong.json",
    "verify": "node verify.mjs"
  },
  "devDependencies": {
    "@cucumber/cucumber": "13.3.0",
    "@stryker-mutator/core": "10.0.0",
    "fast-check": "4.10.2"
  }
}

property.mjs

Download this file

import fc from 'fast-check';
const buggy = process.argv.includes('--buggy');
const { deliveryPence } = await import(buggy ? './src/delivery-buggy.mjs' : './src/delivery.mjs');

// The requirement is independent of the implementation: every basket from
// 5000p to 10000p must get free delivery. This is generated sampling, not an
// exhaustive search of every integer in that range.
const property = fc.property(
  fc.integer({ min: 5000, max: 10000 }),
  basketPence => deliveryPence(basketPence) === 0,
);
const result = fc.check(property, {
  numRuns: 1000,
  seed: 20261015,
  ...(process.env.REPLAY_PATH ? { path: process.env.REPLAY_PATH } : {}),
});
const summary = {
  fixture: buggy ? 'buggy' : 'fixed',
  failed: result.failed,
  seed: result.seed,
  path: result.counterexamplePath,
  counterexample: result.counterexample,
  numRuns: result.numRuns,
  numShrinks: result.numShrinks,
};
console.log(JSON.stringify(summary, null, 2));
if (result.failed) process.exitCode = 1;

verify.mjs

Download this file

import assert from 'node:assert/strict';
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { spawnSync } from 'node:child_process';
mkdirSync('results', { recursive: true });
const commands = [
  ['test:weak', 0], ['test:weak:bug', 0], ['test', 0], ['test:property:bug', 1],
  ['test:property', 0], ['test:gherkin:bug', 1], ['test:gherkin', 0],
  ['test:mutation:weak', 0], ['test:mutation:strong', 0],
];
for (const [name, expected] of commands) {
  const run = spawnSync('npm', ['run', name], { encoding: 'utf8' });
  writeFileSync(`results/${name.replaceAll(':', '-')}.txt`, `${run.stdout || ''}${run.stderr || ''}`);
  assert.equal(run.status, expected, `${name}: expected exit ${expected}, received ${run.status}\n${run.stderr}`);
  console.log(`${name}: observed expected exit ${expected}`);
}
const propertyOutput = readFileSync('results/test-property-bug.txt', 'utf8');
const buggyProperty = JSON.parse(propertyOutput.slice(propertyOutput.indexOf('{')));
assert.deepEqual(buggyProperty.counterexample, [5000]);
const replay = spawnSync(process.execPath, ['property.mjs', '--buggy'], {
  encoding: 'utf8', env: { ...process.env, REPLAY_PATH: buggyProperty.path },
});
assert.equal(replay.status, 1, 'the replay must reproduce the expected failure');
assert.deepEqual(JSON.parse(replay.stdout).counterexample, [5000]);
writeFileSync('results/property-replay.json', replay.stdout);
const weak = JSON.parse(readFileSync('results/mutation-weak.json', 'utf8'));
const strong = JSON.parse(readFileSync('results/mutation-strong.json', 'utf8'));
const mutants = report => Object.values(report.files).flatMap(file => file.mutants);
const boundary = mutants(weak).find(mutant => mutant.replacement === 'basketPence > 5000');
assert.equal(boundary?.status, 'Survived', 'weak tests must miss the boundary mutation');
const strongerBoundary = mutants(strong).find(mutant => mutant.replacement === 'basketPence > 5000');
assert.equal(strongerBoundary?.status, 'Killed', 'boundary assertion must kill the boundary mutation');
const counts = report => mutants(report).reduce((out, mutant) => {
  out[mutant.status] = (out[mutant.status] || 0) + 1;
  return out;
}, {});
writeFileSync('results/summary.json', JSON.stringify({
  provenance: 'Owned fictional fixture, executed locally. No AI calls, hosted Cue April run or customer data.',
  verifiedOn: '2026-10-15', node: process.version,
  versions: { 'fast-check': '4.10.2', '@stryker-mutator/core': '10.0.0', '@cucumber/cucumber': '13.3.0' },
  property: buggyProperty,
  mutation: { weak: counts(weak), strong: counts(strong), boundaryBefore: boundary, boundaryAfter: strongerBoundary },
}, null, 2));
console.log('Verified property counterexample and boundary mutation before/after.');

stryker.weak.json

Download this file

{
  "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
  "mutate": ["src/delivery.mjs"],
  "testRunner": "command",
  "commandRunner": { "command": "node --test test/weak.test.mjs" },
  "coverageAnalysis": "off",
  "concurrency": 1,
  "reporters": ["clear-text", "json"],
  "jsonReporter": { "fileName": "results/mutation-weak.json" },
  "tempDirName": ".stryker-tmp-weak"
}

stryker.strong.json

Download this file

{
  "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
  "mutate": ["src/delivery.mjs"],
  "testRunner": "command",
  "commandRunner": { "command": "node --test test/strong.test.mjs" },
  "coverageAnalysis": "off",
  "concurrency": 1,
  "reporters": ["clear-text", "json"],
  "jsonReporter": { "fileName": "results/mutation-strong.json" },
  "tempDirName": ".stryker-tmp-strong"
}

README.md

Download this file

# Reproduce the business-rule examples

Owned educational fixture, verified locally on 15 October 2026. It contains a deliberately seeded delivery-boundary defect. The defect was deliberately seeded for teaching. No customer data is used, execution makes no AI calls, and these are not hosted Cue April results or an evaluation of a coding assistant.

Requirement: delivery costs 500p below 5000p (£50), and is free from 5000p. Inputs in these examples are non-negative integer pence; the property generator is bounded to 5000..10000 inclusive. Input validation and other invoice behaviour are outside this fixture.

## Run

Install Node 24. Extract the ZIP, open the `testing-business-rules` folder, and run:

```sh
npm ci --ignore-scripts
npm run verify
```

The package lockfile pins the dependency tree. Verified with Node 24.21.0, fast-check 4.10.2, Stryker 10.0.0 and Cucumber.js 13.3.0. Stryker uses a temporary local worker logging socket.

`verify` expects the deliberately buggy commands to fail. It succeeds only when the weak tests pass, the known property counterexample is found and replayed, the expected Cucumber outcomes occur, and the boundary mutant survives the weak suite but is killed by the added boundary assertion. It saves a fresh summary and native reports under `results/`.

## Run each method

```sh
npm run test:weak:bug          # 2 tests pass despite the seeded bug
npm run test:property:bug      # intentionally exits 1, counterexample [5000]
REPLAY_PATH=26 npm run test:property:bug  # same failure, seed 20261015
npm run test:property          # corrected function, 1000 generated cases pass
npm run test:gherkin:bug       # intentionally exits 1, 1 of 3 scenarios fails
npm run test:gherkin           # corrected function, 3 scenarios pass
npm run test:mutation:weak     # 4 killed, 1 surviving mutant in this fixture
npm run test:mutation:strong   # boundary assertion kills the former survivor
```

The replay environment-variable syntax shown above is for POSIX shells. On PowerShell set `$env:REPLAY_PATH='26'` before the command and remove it afterwards. `npm run verify` performs the replay portably through Node.

The corrected implementation is in `src/delivery.mjs`; the intentional defect is in `src/delivery-buggy.mjs`. The weak mutation suite checks 4999p and 5001p. The strong suite also checks exactly 5000p. Mutation testing targets only the corrected source file and injects controlled changes into an isolated copy.

## Recorded results and limits

- fast-check found the known boundary defect after 27 generated cases with seed 20261015, path 26 and counterexample [5000]. No shrinking was needed. The corrected property passed 1000 requested cases.
- Cucumber's buggy run: 2 scenarios passed and 1 failed. Corrected run: 3 scenarios passed.
- Native Stryker weak report: 5 mutants, 4 killed and 1 survived. The survivor changed >= to >. Strong report: all 5 killed.

These results describe only this deliberately small local fixture. They do not establish a model benchmark, complete input coverage, a production release decision or performance of hosted Cue April agents. The homepage's 10,001-input browser enumeration and the separate older sample report are different examples; do not add their counts to these results.

Published log copies normalise the local working-directory path to `<example-root>` and temporary sandbox suffixes are retained. The tested code, recorded outcomes and counts are unchanged. Original local logs remain in the implementation report directory. `SHA256SUMS` fingerprints this published package; reruns can change timings and temporary paths.

## Primary documentation

- https://fast-check.dev/docs/core-blocks/runners/
- https://fast-check.dev/docs/api/interfaces/Parameters/
- https://stryker-mutator.io/docs/stryker-js/configuration/
- https://cucumber.io/docs/gherkin/reference/
- https://github.com/cucumber/cucumber-js/blob/main/docs/support_files/step_definitions.md

src/delivery-buggy.mjs

Download this file

// Deliberately seeded boundary defect: exactly £50 incorrectly costs 500p.
export function deliveryPence(basketPence) {
  return basketPence > 5000 ? 0 : 500;
}

src/delivery.mjs

Download this file

// Fictional requirement: delivery costs 500p below £50 and is free from £50.
// The example accepts a non-negative integer basket value in pence.
export function deliveryPence(basketPence) {
  return basketPence >= 5000 ? 0 : 500;
}

test/strong.test.mjs

Download this file

import assert from 'node:assert/strict';
import { test } from 'node:test';
import { deliveryPence } from '../src/delivery.mjs';

test('charges below the threshold', () => assert.equal(deliveryPence(4999), 500));
test('is free at the threshold', () => assert.equal(deliveryPence(5000), 0));
test('is free above the threshold', () => assert.equal(deliveryPence(5001), 0));

test/weak-bug.test.mjs

Download this file

import assert from 'node:assert/strict';
import { test } from 'node:test';
import { deliveryPence } from '../src/delivery-buggy.mjs';

// These deliberately incomplete examples pass against the seeded defect.
test('charges below the threshold', () => assert.equal(deliveryPence(4999), 500));
test('is free above the threshold', () => assert.equal(deliveryPence(5001), 0));

test/weak.test.mjs

Download this file

import assert from 'node:assert/strict';
import { test } from 'node:test';
import { deliveryPence } from '../src/delivery.mjs';

test('charges below the threshold', () => assert.equal(deliveryPence(4999), 500));
test('is free above the threshold', () => assert.equal(deliveryPence(5001), 0));

features/delivery.feature

Download this file

Feature: Delivery charges
  Delivery costs 500p below £50 and is free from £50.

  Scenario Outline: The basket determines the delivery charge
    Given a basket worth <basket> pence
    When I calculate its delivery charge
    Then the charge is <charge> pence

    Examples:
      | basket | charge |
      | 4999   | 500    |
      | 5000   | 0      |
      | 5001   | 0      |

features/steps.mjs

Download this file

import assert from 'node:assert/strict';
import { Given, When, Then } from '@cucumber/cucumber';
import { deliveryPence } from '../src/delivery.mjs';
import { deliveryPence as buggyDeliveryPence } from '../src/delivery-buggy.mjs';

Given('a basket worth {int} pence', function (basketPence) {
  this.basketPence = basketPence;
});
When('I calculate its delivery charge', function () {
  const calculate = this.parameters.buggy ? buggyDeliveryPence : deliveryPence;
  this.chargePence = calculate(this.basketPence);
});
Then('the charge is {int} pence', function (expectedPence) {
  assert.equal(this.chargePence, expectedPence);
});