| name | slic |
| description | Guide for creating, modifying, and running WPUnit integration tests with slic (StellarWP Local Interactive Containers). Covers slic workflow, test structure, environment setup, HTTP mocking, WordPress factories, assertions, and Codeception/wp-browser patterns. Use when writing or debugging WordPress plugin integration tests. |
| license | MIT |
| compatibility | Requires Docker and slic CLI on PATH |
| metadata | {"author":"stellarwp","version":"1.0"} |
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 run workflow)
- 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
slic here
slic here
2. Select the target project
slic use my-plugin
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
slic run wpunit
slic run tests/wpunit/FooTest.php
slic run tests/wpunit/FooTest::test_something
5. Interactive shell (optional)
slic shell
> cr wpunit
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) or lucatume\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 @test annotations).
- Isolate — every test must pass in any order. Clean up in
tearDown().
- Use factories — prefer
$this->factory()->post->create() over raw SQL or wp_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:
Testing patterns
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
External resources