Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 2, 2025

Created comprehensive Behat tests documentation guide:

  • Create new guide file guides/behat-tests.md with comprehensive Behat testing documentation
    • Introduction section: What are Behat tests, why they matter, getting started
    • Writing your first test: Basic structure, common steps, running tests
    • Advanced usage section: Effective tests, variables, structured output, error testing, custom steps
    • Best practices: Do's and don'ts for writing maintainable tests
    • Scaffolding and troubleshooting sections
    • Additional resources and examples
  • Update guides.md to include link to new Behat tests guide
  • Update index.md to include link to new Behat tests guide
  • Update bin/handbook-manifest.json to register the new guide
  • Update contributions/pull-requests.md to link to the new comprehensive guide
  • Update guides/external-resources.md to add the Delicious Brains article
  • Address review feedback: Add SQLite option and improve database setup documentation
    • Recommend SQLite as the easiest option (no database setup required)
    • Remove manual MySQL database creation steps
    • Emphasize using composer prepare-tests for MySQL setup
    • Update troubleshooting section to mention SQLite first
  • Document automatic SQLite fallback behavior
    • Note that composer behat automatically detects database availability
    • Falls back to SQLite if no running database is found
    • Makes getting started even easier with zero configuration

The guide now clearly explains that contributors can simply run composer behat without any database setup, as it will automatically use SQLite when needed.

Original prompt

This section details on the original issue you should resolve

<issue_title>Create a dedicated doc for how to write Behat tests</issue_title>
<issue_description>WP-CLI integration test documentation exists in two places:

It would be more user-friendly to have an uberdoc for Behat tests. We could have two sections:

  1. Introduction - Getting started, and writing your first test
  2. Advanced usage - Now that you've written a test, here's how you write steps, etc.

Once this document exists, we can have both existing places link directly to it.

Related https://deliciousbrains.com/writing-functional-tests-wp-cli-packages/</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Create dedicated documentation for writing Behat tests Add comprehensive Behat testing guide to handbook Nov 2, 2025
Copilot AI requested a review from swissspidy November 2, 2025 15:20
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI requested a review from swissspidy November 2, 2025 16:27
@swissspidy swissspidy marked this pull request as ready for review November 2, 2025 16:56
@swissspidy swissspidy requested a review from a team as a code owner November 2, 2025 16:56
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR creates a comprehensive Behat testing guide for WP-CLI contributors, consolidating documentation that was previously scattered across multiple locations. The new guide provides clear, structured documentation for writing functional tests, including SQLite as a recommended easy setup option.

Changes:

  • Added new comprehensive Behat testing guide at guides/behat-tests.md covering introduction, writing tests, advanced usage, best practices, and troubleshooting
  • Updated handbook navigation files (index.md, guides.md) and manifest to include the new guide
  • Modified contributions/pull-requests.md to reference the comprehensive guide instead of duplicating content
  • Added the Delicious Brains article to external resources

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
guides/behat-tests.md New comprehensive guide covering all aspects of Behat testing for WP-CLI, including setup with SQLite/MySQL, writing tests, advanced features, and troubleshooting
index.md Added link to new Behat testing guide in the guides section
guides.md Added link to new Behat testing guide
contributions/pull-requests.md Streamlined functional tests section to reference the comprehensive guide, removing duplicated content
guides/external-resources.md Added Delicious Brains article on writing functional tests
bin/handbook-manifest.json Registered the new behat-tests guide page
Comments suppressed due to low confidence (1)

contributions/pull-requests.md:138

  • The code block is tagged with 'yml' language identifier, but Behat feature files use Gherkin syntax, not YAML. While the syntax highlighting might work, it would be more accurate to use 'gherkin' or 'cucumber' as the language identifier for better semantic accuracy.
```yml
Feature: Manage WordPress options

  Scenario: Read an individual option
    Given a WP install

	When I run `wp option get home`
	Then STDOUT should be:
      """
	  https://example.com
	  """
</details>



---

💡 <a href="/wp-cli/handbook/new/main/.github/instructions?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.


### Getting Started

Every WP-CLI repository with commands has a `features/` directory containing one or more YAML-formatted `*.feature` files.
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The statement that feature files are "YAML-formatted" is incorrect. Behat feature files use Gherkin syntax, not YAML. While both use indentation and have a structured format, Gherkin is its own domain-specific language. This should be corrected to avoid confusion.

Suggested change
Every WP-CLI repository with commands has a `features/` directory containing one or more YAML-formatted `*.feature` files.
Every WP-CLI repository with commands has a `features/` directory containing one or more `*.feature` files written in Gherkin syntax.

Copilot uses AI. Check for mistakes.
* [Torque: Using WP CLI to Set Up a Test Version of Your Site](https://torquemag.io/using-wp-cli-to-set-up-a-test-version-of-your-site/)
* [WP Bullet Guides: Useful Bash Scripts Utilizing WP-CLI](https://guides.wp-bullet.com/category/wp-cli/)
* [WP Bullet Guides: Useful Bash Scripts Utilizing WP-CLI](https://guides.wp-bullet.com/category/wp-cli/)
* [Delicious Brains: Writing Functional Tests for WP-CLI Packages](https://deliciousbrains.com/writing-functional-tests-wp-cli-packages/)
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace at the end of this line that should be removed.

Suggested change
* [Delicious Brains: Writing Functional Tests for WP-CLI Packages](https://deliciousbrains.com/writing-functional-tests-wp-cli-packages/)
* [Delicious Brains: Writing Functional Tests for WP-CLI Packages](https://deliciousbrains.com/writing-functional-tests-wp-cli-packages/)

Copilot uses AI. Check for mistakes.
Comment on lines 148 to 150
#### Creating a test database

Before running the functional tests, you'll need a MySQL (or MariaDB) user called `wp_cli_test` with the password `password1` that has full privileges on the MySQL database `wp_cli_test`.
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section only mentions MySQL/MariaDB database setup, but the new comprehensive guide recommends SQLite as the easiest option. Consider adding a note here that SQLite can be used as an alternative by setting WP_CLI_TEST_DBTYPE=sqlite, which requires no database setup. This would be consistent with the new guide and provide a simpler path for contributors.

Copilot uses AI. Check for mistakes.
@swissspidy swissspidy merged commit d24ce0c into main Jan 20, 2026
6 checks passed
@swissspidy swissspidy deleted the copilot/create-behat-tests-doc branch January 20, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a dedicated doc for how to write Behat tests

2 participants