This guide covers how to run tests in InvoicePlane v2, including full test suites, smoke tests, and specific test groups.
composer install
cp .env.testing.example .env.testing
php artisan key:generate --env=testing# Using Laravel Artisan (recommended)
php artisan test
# Using PHPUnit directly
./vendor/bin/phpunit# Run only Unit tests
php artisan test --testsuite=Unit
# Run only Feature tests
php artisan test --testsuite=FeatureSmoke tests are fast, critical tests that verify core functionality. They use the #[Group('smoke')] attribute.
# Using PHPUnit with smoke configuration
php artisan test --configuration=phpunit.smoke.xml
# Using --group flag
php artisan test --group=smoke
# Run smoke tests for a specific module
./vendor/bin/phpunit Modules/Clients/Tests/Feature/ --group=smoke# Generate coverage report
php artisan test --coverage
# Generate HTML coverage report
php artisan test --coverage-html coverage/
# View coverage in browser
open coverage/index.html # macOS
xdg-open coverage/index.html # LinuxInvoicePlane v2 uses PHPUnit groups to organize tests:
smoke- Fast, critical tests (runs in ~10-30 seconds)crud- Create, Read, Update, Delete operation testspeppol- Peppol e-invoicing integration testsintegration- Integration tests with external services
# Smoke tests only
php artisan test --group=smoke
# CRUD tests only
php artisan test --group=crud
# Peppol tests only
php artisan test --group=peppol
# Multiple groups
php artisan test --group=smoke,crud# All tests for a module
./vendor/bin/phpunit Modules/Clients/Tests/
# Only Feature tests for a module
./vendor/bin/phpunit Modules/Clients/Tests/Feature/
# Only Unit tests for a module
./vendor/bin/phpunit Modules/Clients/Tests/Unit/# Clients module
./vendor/bin/phpunit Modules/Clients/Tests/
# Invoices module
./vendor/bin/phpunit Modules/Invoices/Tests/
# Peppol-specific tests
./vendor/bin/phpunit Modules/Invoices/Tests/Unit/Peppol/# Run a specific test file
./vendor/bin/phpunit Modules/Clients/Tests/Feature/ContactsTest.php
# Run a specific test method
./vendor/bin/phpunit --filter it_lists_contacts Modules/Clients/Tests/Feature/ContactsTest.phpphp artisan test --stop-on-failurephp artisan test --verbose./vendor/bin/phpunit --debug# Using --filter
php artisan test --filter it_creates_invoice
# Pattern matching
php artisan test --filter ".*creates.*"For faster test execution, ParaTest can be used (if installed in the project):
# Run tests in parallel (if ParaTest is available)
./vendor/bin/paratest
# Run with specific number of processes
./vendor/bin/paratest --processes=4Note: ParaTest should be added to composer.json as a dev dependency if parallel testing is needed:
composer require --dev brianium/paratestInvoicePlane v2 uses two PHPUnit configuration files:
phpunit.xml- Default configuration for all testsphpunit.smoke.xml- Configuration for smoke tests only
- Runs all Unit and Feature test suites
- Uses SQLite in-memory database
- Includes all test directories
- Filters tests by
#[Group('smoke')]attribute - Faster execution (~10-30 seconds)
- Ideal for CI/CD pipelines and post-deployment checks
Smoke tests run automatically after Composer dependency updates:
# See .github/workflows/composer-update.ymlFull test suite runs manually:
# See .github/workflows/phpunit.yml- Run smoke tests frequently - They catch critical issues quickly
- Use
--stop-on-failure- When debugging to save time - Run full suite before committing - Ensure no regressions
- Use coverage reports - To identify untested code
- Group tests logically - Use
#[Group()]for better organization
# Ensure .env.testing is configured
cp .env.testing.example .env.testing
php artisan key:generate --env=testing
# Check database connection
php artisan test --env=testing# Increase PHP memory limit
php -d memory_limit=512M artisan test# Clear all caches
php artisan cache:clear
php artisan config:clear
php artisan view:clear- CONTRIBUTING.md - Guidelines for contributing tests
- TEST_GENERATION_SUMMARY.md - Test generation documentation
- PEPPOL_TESTS_SUMMARY.md - Peppol-specific test documentation