slic — WPUnit Integration Testing Guide
When to use this skill
Activate this skill when:
- Writing new WPUnit integration tests for a WordPress plugin or theme
- Modifying or debugging existing Codeception/wp-browser tests
- Running test suites through slic (the
slic runworkflow) - Setting up a project for slic-based testing for the first time
- Diagnosing flaky or order-dependent test failures
Quick-start workflow
slic orchestrates Docker containers (MariaDB, Redis, WordPress, Chrome, and a Codeception runner) so you never configure a local test environment manually.
1. Point slic at your code
# From a plugins directory (e.g. wp-content/plugins):
slic here
# Or from a full WordPress root (where wp-config.php lives):
slic here
2. Select the target project
slic use my-plugin
# Subdirectory targets are supported:
slic use event-tickets/common
3. Initialize (first time only)
slic init my-plugin
This generates three files in the plugin root:
| File | Purpose |
|---|---|
.env.testing.slic |
Database credentials, WordPress URL, container paths |
codeception.slic.yml |
Loads .env.testing.slic as Codeception params |
test-config.slic.php |
Optional WPLoader custom configuration |
4. Run tests
slic run # all suites, sequentially
slic run wpunit # one suite
slic run tests/wpunit/FooTest.php # one file
slic run tests/wpunit/FooTest::test_something # one method
5. Interactive shell (optional)
slic shell
# Inside the container:
> cr wpunit # shorthand for codecept run
Test creation rules
When creating or modifying a test file, follow these rules:
- Extend
WPTestCase— every WPUnit test class extends\Codeception\TestCase\WPTestCase(wp-browser v3) orlucatume\WPBrowser\TestCase\WPTestCase(wp-browser v4). - Use the AAA pattern — Arrange, Act, Assert. Keep each section visually distinct.
- Name clearly — file:
<DescriptiveName>Test.php; methods:test_<what_it_verifies>(preferred over@testannotations). - Isolate — every test must pass in any order. Clean up in
tearDown(). - Use factories — prefer
$this->factory()->post->create()over raw SQL orwp_insert_post()in test setup. - Follow WordPress coding standards — tabs for indentation, spaces inside parentheses.
See test-anatomy.md for the complete file skeleton and naming rules.
Environment setup tiers
Choose the right level of setUp/tearDown for your test:
| Tier | When to use | Guide |
|---|---|---|
| Minimal | Tests that only need WordPress loaded | environment-setup.md |
| Standard | Tests that create posts, users, or terms | environment-setup.md |
| Full isolation | Tests that mock HTTP, change globals, or modify options | environment-setup.md |
Testing patterns
| Pattern | Guide |
|---|---|
| HTTP mocking (3 approaches) | http-mocking.md |
| Assertions and WordPress factories | assertions.md |
| REST dispatch, Reflection, custom tables | advanced-patterns.md |
| Test isolation checklist (11 items) | test-isolation-checklist.md |
Verification workflow
After writing or modifying tests, follow this sequence:
- Write the code under test (or confirm it exists).
- Create or update tests following the patterns above.
- Run the targeted test —
slic run tests/wpunit/YourTest.php. - Run the full suite —
slic run wpunit— to catch side effects. - Fix any failures and re-run.
- Verify isolation — run the single test again to confirm it passes independently.
- Check the isolation checklist before committing.
Reference material
| Topic | File |
|---|---|
| Complete slic CLI command reference | references/slic-commands.md |
| Installation, setup, env files, CI | references/slic-setup.md |
| WPLoader config and WPTestCase API | references/wp-browser-wploader.md |
External resources
Source: stellarwp/slic — distributed by TomeVault.