- How does Pyrameter categorize tests in a Laravel project? Does it rely on naming conventions or annotations?
- Pyrameter uses a combination of test naming patterns, annotations (like `@testUnit`), and code analysis to classify tests into unit, functional, integration, or E2E categories. By default, it follows common Laravel conventions (e.g., `*Test.php` for unit tests) but allows customization via regex rules in the `pyrameter.php` config file. You can override its logic if your project uses non-standard naming.
- Will Pyrameter work with Laravel’s default PHPUnit setup without extra configuration?
- Yes, Pyrameter integrates seamlessly with Laravel’s built-in PHPUnit setup. After installing via Composer, you only need to add the listener to your `phpunit.xml` file. No additional Laravel-specific dependencies or changes to your existing test structure are required. It runs as a post-test extension, so it won’t interfere with test execution.
- Can I use Pyrameter in CI/CD to block merges if the test pyramid is violated?
- Absolutely. Pyrameter is designed for CI/CD enforcement. Configure it in your pipeline (e.g., GitHub Actions) as a post-test step, and it will fail the build if your test distribution deviates from your target pyramid shape. You can set thresholds in the config to define what constitutes a violation, such as requiring at least 70% unit tests or capping E2E tests at 2%.
- What Laravel versions and PHPUnit setups does Pyrameter support?
- Pyrameter supports Laravel 8+ and PHPUnit 9.5+ out of the box. For older Laravel versions (7 or below), you may need to use PHPUnit polyfills or ensure your PHPUnit version is compatible. It doesn’t require any Laravel-specific features, so it works with any PHPUnit-based test suite, including custom configurations.
- How do I handle false positives, like flaky tests or intentionally heavy E2E suites?
- Pyrameter allows you to configure exceptions for justified deviations in your `pyrameter.php` file. For example, you can exclude specific test classes or methods from the pyramid analysis. If flaky tests are causing issues, consider refactoring them into more stable categories (e.g., moving flaky E2E tests to integration) or using annotations to override Pyrameter’s classification for edge cases.
- Does Pyrameter add significant runtime overhead to my Laravel application or test suite?
- No, Pyrameter runs as a post-test extension and doesn’t impact your application’s runtime performance. The analysis happens after all tests complete, so there’s no overhead during test execution or when your Laravel app is running. The only potential delay is in your CI pipeline if you’re running it as a post-test step, but this is typically negligible.
- Can I integrate Pyrameter’s reports into existing dashboards like Allure or QAWolf?
- Pyrameter generates a detailed CLI output, but it doesn’t natively integrate with dashboards like Allure or QAWolf. However, you can parse its output and feed it into your existing tools via custom scripts or CI plugins. For example, you could use a GitHub Actions step to log Pyrameter’s results to a Slack channel or a custom metrics dashboard.
- What’s the best way to migrate an existing Laravel test suite to comply with Pyrameter’s rules?
- Start by running Pyrameter in dry mode (logging violations without failing) to audit your current test distribution. Document discrepancies, such as tests mislabeled as unit but actually being integration tests. Then, standardize your test naming or annotations (e.g., enforce `@testUnit` for unit tests) and refactor tests to match the pyramid. Finally, enable Pyrameter as a CI gate and configure exceptions for justified deviations.
- Are there alternatives to Pyrameter for enforcing test pyramid rules in Laravel?
- Few tools specifically enforce test pyramid rules like Pyrameter does. Some alternatives include custom PHPUnit listeners or scripts that manually classify and count tests, but these require more setup and maintenance. Tools like Pest (for Laravel) focus on test writing rather than enforcement, while Pyrameter provides a turnkey solution with configurable rules and CI integration.
- How do I customize Pyrameter’s test categorization logic for my Laravel project?
- Customize Pyrameter’s categorization by editing the `pyrameter.php` config file. You can define regex patterns to match test class/method names, specify annotations (e.g., `@testIntegration`), or override default rules for specific test files. For example, if your project uses `Feature` tests for integration, you can map them explicitly. The config also lets you adjust target percentages for each test type.