Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Specify Laravel Package

codeception/specify

BDD-style specifications for PHP tests, built as a lightweight extension for Codeception. Adds a clean “specify” syntax to structure examples and expectations, making tests easier to read, write, and maintain across unit and functional suites.

Deep Wiki
Context7

codeception/specify adds a concise BDD-style layer on top of PHPUnit/Codeception, letting you write readable, behavior-focused tests with minimal ceremony. It helps structure scenarios in a clean “specification” format while staying compatible with your existing PHP test suite.

Use it to express intent clearly, reduce duplication, and keep tests maintainable as your codebase grows.

  • Write specs with specify() blocks for clear scenario grouping
  • Data-driven examples via simple providers and parameters
  • Common setup/teardown hooks per specification
  • Improved readability and reduced boilerplate in unit tests
  • Integrates smoothly with Codeception and PHPUnit workflows
Frequently asked questions about Specify
Can I use `codeception/specify` with Laravel 10 and PHPUnit 10+?
The package was last updated in 2021 and may require testing with Laravel 10/PHPUnit 10+. Start by pinning to `^1.0` in `composer.json` and verify compatibility in your CI pipeline. If issues arise, consider forking or patching the package, as it lacks active maintenance.
How does `specify()` improve Laravel feature tests compared to vanilla PHPUnit?
`specify()` introduces BDD-style syntax (e.g., `describe()`, `it()`) to group related test scenarios, reducing boilerplate and making tests more readable. In Laravel, this is especially useful for feature tests where behavior-driven language aligns better with business requirements than procedural `testX()` methods.
Will `codeception/specify` conflict with Codeception’s built-in BDD extensions?
Yes, conflicts may occur if you’re already using `codeception/bdd` or similar extensions. Audit your `composer.json` and test suite for overlapping keywords like `describe()` or `it()`. If conflicts exist, prioritize one BDD layer or use a hybrid approach for new vs. legacy tests.
How do I migrate existing Laravel PHPUnit tests to `specify()` syntax?
Start by converting one test file to `specify()` syntax, replacing `public function testX()` with `it('does X')` and wrapping related tests in `describe()`. Use `beforeEach()` for shared setup. Gradually refactor tests to avoid breaking changes, and validate coverage in CI before full adoption.
Does `codeception/specify` support data-driven testing in Laravel?
Yes, it provides simple providers and parameters for data-driven examples, similar to PHPUnit’s `dataProvider`. This is useful for Laravel’s unit tests (e.g., testing validation rules or model behaviors) where you need to test multiple input/output scenarios concisely.
Is `codeception/specify` a good alternative to Pest for Laravel BDD testing?
Pest is a more modern, actively maintained alternative with deeper Laravel integration (e.g., Pest’s `expect()` helpers). If your team prioritizes long-term support and Laravel-specific features, Pest may be a better fit. `specify` is lighter but lacks updates and advanced tooling.
How do I configure `codeception/specify` in Laravel’s `phpunit.xml`?
No special configuration is needed beyond ensuring autoloading includes your test directory. Add this to `phpunit.xml` if missing: `<autoload><classmap><dir>./tests</dir></classmap></autoload>`. The package works as a drop-in extension for existing PHPUnit/Codeception setups.
Will using `specify()` slow down Laravel test execution?
The overhead is minimal, primarily from parsing BDD syntax. For large test suites, benchmark performance before/after adoption. If speed is critical, procedural tests may suffice, but the readability gains often outweigh minor performance trade-offs.
Can I mix `codeception/specify` with Laravel’s Pest framework?
No, Pest and `specify` serve overlapping purposes and cannot be used together in the same test suite. Choose one based on your needs: Pest for modern Laravel BDD, `specify` for lightweight PHPUnit/Codeception compatibility.
How do I handle database transactions in Laravel tests with `specify()`?
Use `beforeEach()` to wrap database transactions or service containers, just like in vanilla PHPUnit. Example: `beforeEach(function () { $this->refreshDatabase(); })`. This ensures clean state per test, which is critical for Laravel’s dependency-heavy test suites.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport