Add @skip-<dbtype> tags for database-specific test exclusion#302
Add @skip-<dbtype> tags for database-specific test exclusion#302swissspidy merged 3 commits intomainfrom
@skip-<dbtype> tags for database-specific test exclusion#302Conversation
- Updated utils/behat-tags.php to add skip tags based on database type - Updated all test cases in tests/tests/TestBehatTags.php to expect new skip tags - Added new test method test_behat_tags_skip_db_type to specifically test the skip tags Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…ing.feature Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@skip-<dbtype> tags for database-specific test exclusion
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds support for database-specific Behat skip tags (@skip-mysql, @skip-mariadb, @skip-sqlite) so scenarios can be excluded automatically based on the active DB engine, complementing the existing @require-* tagging.
Changes:
- Extend
utils/behat-tags.phpto emit DB-type-specific skip exclusions (~@skip-<dbtype>) for the active database. - Update PHPUnit expectations and add a dedicated unit test covering the new skip-tag output.
- Add Behat feature examples demonstrating each
@skip-*tag.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| utils/behat-tags.php | Adds @skip-<dbtype> tags to the generated exclusion list for the active DB type. |
| tests/tests/TestBehatTags.php | Updates expected tag expressions and adds test_behat_tags_skip_db_type() coverage. |
| features/testing.feature | Adds example scenarios tagged with @skip-mysql, @skip-mariadb, and @skip-sqlite. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| file_put_contents( $this->temp_dir . '/features/skip_db.feature', '@skip-mysql @skip-mariadb @skip-sqlite' ); | ||
|
|
There was a problem hiding this comment.
behat-tags.php adds the DB-specific @skip-* exclusions unconditionally based on the active DB type; this test doesn’t need to write a feature file containing @skip-* tags for the output to change. Consider removing this file_put_contents() (or adding a brief comment explaining why it’s needed) to avoid implying the script parses @skip-* tags from feature files.
| file_put_contents( $this->temp_dir . '/features/skip_db.feature', '@skip-mysql @skip-mariadb @skip-sqlite' ); |
| @skip-mysql | ||
| Scenario: Skip on MySQL databases | ||
| Given a WP install | ||
|
|
||
| When I run `wp eval 'echo "This should only run on MariaDB or SQLite";'` | ||
| Then STDOUT should contain: | ||
| """ | ||
| This should only run on MariaDB or SQLite | ||
| """ |
There was a problem hiding this comment.
These scenarios are intended to demonstrate/verify @skip-* behavior, but the steps/assertions are database-agnostic (they just echo a static string). If the skip-tag implementation regresses and scenarios run on the “skipped” DB, they will still pass and won’t catch it. Consider making each scenario contain a DB-specific step that would fail on the skipped DB (e.g., combine @require-mysql-or-mariadb with @skip-mysql and assert SELECT VERSION() contains MariaDB, and use @skip-sqlite with a SHOW TABLES assertion).
| @skip-mariadb | ||
| Scenario: Skip on MariaDB databases | ||
| Given a WP install | ||
|
|
||
| When I run `wp eval 'echo "This should only run on MySQL or SQLite";'` | ||
| Then STDOUT should contain: | ||
| """ | ||
| This should only run on MySQL or SQLite | ||
| """ |
There was a problem hiding this comment.
This scenario’s assertion is a static echo, so it will pass on any database if @skip-mariadb is not applied correctly. To actually validate @skip-mariadb, make the scenario fail on MariaDB (or assert it is running on MySQL) using a DB-specific query/output check.
| @skip-sqlite | ||
| Scenario: Skip on SQLite databases | ||
| Given a WP install | ||
|
|
||
| When I run `wp eval 'echo "This should only run on MySQL or MariaDB";'` | ||
| Then STDOUT should contain: | ||
| """ | ||
| This should only run on MySQL or MariaDB | ||
| """ |
There was a problem hiding this comment.
Same issue here: the scenario will succeed regardless of DB type because it only checks a static string. If the goal is to ensure @skip-sqlite works, consider using a query that would fail on SQLite (e.g. SHOW TABLES) so the scenario fails if it accidentally runs under SQLite.
Adds support for
@skip-mysql,@skip-mariadb, and@skip-sqliteBehat tags to skip scenarios based on the active database type.Implementation
utils/behat-tags.php: Adds skip tags to the exclusion list based on detected database type, mirroring the existing@require-<dbtype>patterntests/tests/TestBehatTags.php: Updates test expectations and addstest_behat_tags_skip_db_type()coveragefeatures/testing.feature: Adds example scenarios demonstrating each skip tagUsage
The skip tags are applied unconditionally when the behat-tags.php script detects the active database type, complementing the existing require tags for more flexible test control.
Original prompt
skip-<dbtype>tags #301💡 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.