# Moodle behat testing

> Moodle behat testing is an open-source agent skill for developer tools. Guides writing and running Behat acceptance tests for Moodle plugins. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/SaadRahman01/claude-moodle-dev/tree/main/skills/moodle-behat-testing
- **Repository:** https://github.com/saadrahman01/claude-moodle-dev
- **GitHub stars:** 44
- **License:** MIT
- **Skill name:** moodle-behat-testing
- **Collection:** https://github.com/SaadRahman01/claude-moodle-dev
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-02

## About

This skill walks the agent through end-to-end acceptance testing for Moodle plugins with Behat. It covers feature file structure, Background data generators, tags such as @javascript, and custom step definition classes that extend Moodle's base Behat class. It also includes the setup steps for a dedicated Moodle test site, a Selenium or Chromedriver browser driver, and the commands for running tests by tag, file, or scenario line.

The guide includes a selector reference for Mink-based steps, a list of useful built-in Moodle steps, a table of common mistakes, and debugging options such as failure dumps. It also shows a CI job that initializes the test site and runs tagged scenarios. Unit tests for business logic are out of scope and are directed to a separate PHPUnit skill.

Expected inputs are a Moodle codebase with a plugin component, a PHP environment with Composer dependencies, and a browser driver for JavaScript scenarios.

## When your agent uses it

> Use when writing or running Behat acceptance tests for Moodle plugins. Covers feature files, custom step definitions, tags, data generators in Background, JavaScript scenarios, and Selenium/Chromedriver setup.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/SaadRahman01/claude-moodle-dev/tree/HEAD/skills/moodle-behat-testing)
- [License: MIT](https://github.com/SaadRahman01/claude-moodle-dev/tree/HEAD/skills/moodle-behat-testing)

## Features

- **Feature file structure:** Shows how to write Gherkin feature files with scenarios, backgrounds and tags for a Moodle plugin.
- **Custom step definitions:** Explains how to add plugin-specific Behat steps in a class extending the Moodle base class.
- **Data generator setup:** Describes registering plugin generators so test data can be created directly in Background sections.
- **Browser driver configuration:** Covers the test site config values and Selenium or Chromedriver setup for JavaScript scenarios.
- **Selector and step reference:** Lists Mink selector types and commonly used built-in Moodle steps for test writing.
- **Running and debugging tests:** Gives commands for filtering runs by tag, file or line, plus failure dumps and CI usage.

## Good for

- Write a Behat scenario for a plugin's attendance page
- Add a custom step that checks a plugin database count
- Set up a Behat test site with Selenium for JavaScript tests
- Run a single Behat scenario by its line number
- Create test data for a plugin using a generator in a Background

## Install

### Claude Code

This skill ships in the `moodle-dev` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add SaadRahman01/claude-moodle-dev
/plugin install moodle-dev@moodle-dev
```

Or copy only this skill to `~/.claude/skills/moodle-behat-testing`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/moodle-behat-testing &&
cp -R "$tmp/skills/moodle-behat-testing" ~/.claude/skills/moodle-behat-testing &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/moodle-behat-testing` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/moodle-behat-testing` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/moodle-behat-testing &&
cp -R "$tmp/skills/moodle-behat-testing" ~/.agents/skills/moodle-behat-testing &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/moodle-behat-testing` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/moodle-behat-testing` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/moodle-behat-testing &&
cp -R "$tmp/skills/moodle-behat-testing" ~/.cursor/skills/moodle-behat-testing &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/moodle-behat-testing` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/SaadRahman01/claude-moodle-dev.git --path skills/moodle-behat-testing
```

Or copy the folder to `~/.gemini/skills/moodle-behat-testing` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/moodle-behat-testing`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/moodle-behat-testing &&
cp -R "$tmp/skills/moodle-behat-testing" ~/.copilot/skills/moodle-behat-testing &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/moodle-behat-testing` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/SaadRahman01/claude-moodle-dev.git
```

Then copy `claude-moodle-dev/skills/moodle-behat-testing` into your agent's skills folder as `moodle-behat-testing`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When should I use Moodle behat testing instead of unit tests?

The skill is meant for end-to-end and acceptance tests, such as JavaScript-driven UI, bug reproduction needing cookies and sessions, and regression scenarios. It points business logic unit tests to a separate PHPUnit skill.

### Does Moodle behat testing need a browser?

Scenarios tagged @javascript use a real browser through Selenium or Chromedriver. Without that tag, scenarios run headless without JavaScript.

### Do I need to re-run anything after changing step definitions?

Yes, the guide says to re-run the Behat init script after adding or changing PHP step definitions so the steps are rescanned.

### How do I install Moodle behat testing in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/moodle-behat-testing to use it in all your projects, or to .claude/skills/moodle-behat-testing in one project. Or install the moodle-dev plugin, which includes it: /plugin marketplace add SaadRahman01/claude-moodle-dev, then /plugin install moodle-dev@moodle-dev.

### Does Moodle behat testing run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Moodle behat testing?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Moodle behat testing?

The closest alternatives to Moodle behat testing are Moodle phpunit testing, Behat skill, Moodle plugin development, Moodle accessibility and Behave skill.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Moodle phpunit testing](https://ai-powered.com/skills/moodle-phpunit-testing): Moodle phpunit testing is an open-source agent skill for developer tools.
- [Behat skill](https://ai-powered.com/skills/behat-skill): Behat skill is an open-source agent skill for developer tools.
- [Moodle plugin development](https://ai-powered.com/skills/moodle-plugin-development): Moodle plugin development is an open-source agent skill for developer tools.
- [Moodle accessibility](https://ai-powered.com/skills/moodle-accessibility): Moodle accessibility is an open-source agent skill for developer tools.
- [Behave skill](https://ai-powered.com/skills/behave-skill): Behave skill is an open-source agent skill for developer tools.
- [Moodle theme development](https://ai-powered.com/skills/moodle-theme-development): Moodle theme development is an open-source agent skill for developer tools.
- [Moodle amd JavaScript](https://ai-powered.com/skills/moodle-amd-javascript): Moodle amd JavaScript is an open-source agent skill for developer tools.
- [Moodle performance](https://ai-powered.com/skills/moodle-performance): Moodle performance is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/moodle-behat-testing
