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

Trait for BDD-style specifications in PHPUnit/Codeception. Lets you write tests with describe/it-like blocks, shared setup, and clear expectations, improving readability while staying compatible with standard PHP unit testing workflows.

View on GitHub
Deep Wiki
Context7

BDD code blocks for PHPUnit and Codeception

Frequently asked questions about Specify
How does codeception/specify improve Laravel test readability?
Specify replaces verbose PHPUnit methods with BDD-style blocks like `describe()` and `it()`, making tests easier to read and maintain. For example, `it('validates email format')` is clearer than `testEmailValidation()`. It’s especially useful for Laravel’s complex business logic tests where readability impacts collaboration.
Can I use codeception/specify with Laravel 10 and PHP 8.1?
Yes, specify v2.0.0 explicitly supports PHP 8.1+ and integrates seamlessly with Laravel 10’s default PHPUnit (v10). No additional configuration is needed beyond requiring the package via Composer. Always pin to `^2.0` to avoid breaking changes.
Will specify work with Codeception’s acceptance tests?
Specify is designed for unit/feature tests, not Codeception’s acceptance tests. Use Codeception’s native BDD modules (e.g., `codeception/bdd`) for acceptance testing while reserving specify for unit tests. This hybrid approach avoids conflicts and leverages each tool’s strengths.
How do I migrate existing PHPUnit tests to specify’s BDD syntax?
Start by refactoring one test file: replace `public function testX()` with `it('does X')` and wrap assertions in `describe()` blocks. Use `beforeEach()` for shared setup (e.g., database transactions). For Laravel, prioritize tests with complex assertions or shared fixtures—these benefit most from BDD clarity.
Does specify add performance overhead to Laravel tests?
No, specify introduces negligible overhead. The BDD syntax is compiled to standard PHPUnit methods at runtime, so execution speed remains identical to procedural tests. Benchmark your suite post-migration to confirm, but expect minimal impact.
How does specify handle Laravel’s service container and mocking?
Specify integrates with Laravel’s service container like any PHPUnit test. Use `beforeEach()` to mock dependencies (e.g., `$this->mock(Service::class)`) or leverage Laravel’s built-in testing helpers (e.g., `createMock()`). The trait doesn’t interfere with Laravel’s test isolation features like database transactions.
Is specify actively maintained? Should I use it over Pest?
Specify is maintained but niche compared to Pest, Laravel’s native BDD framework. Pest offers deeper Laravel integration (e.g., `expect()` assertions) and is actively developed. Use specify if you prefer lightweight BDD syntax without Pest’s Laravel-specific features or need Codeception compatibility.
Can I mix specify with Pest or native PHPUnit in the same project?
Yes, specify is a drop-in trait and won’t conflict with Pest or native PHPUnit. Use it for new tests where BDD improves readability, while grandfathering legacy tests. Ensure your `composer.json` lists both packages under `require-dev` if needed.
How do I configure specify for Laravel’s CI/CD pipelines?
No special configuration is needed beyond requiring the package. Ensure your CI environment uses PHP 8.1+ and Laravel’s default PHPUnit. For parallel testing, specify’s BDD blocks won’t interfere with PHPUnit’s parallelization. Validate with a test run in your CI pipeline before full deployment.
What are the limitations of specify for Laravel testing?
Specify lacks advanced Codeception features (e.g., acceptance testing) and doesn’t replace Pest’s Laravel-specific helpers (e.g., `actingAs()`). It’s best for unit/feature tests with simple assertions. For complex Laravel workflows (e.g., API testing with JSON responses), consider Pest or native PHPUnit.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai