Test Runner¶
The BerryCrush plugin integrates with IntelliJ's test runner for seamless test execution.
Running Tests¶
From Gutter Icons¶
Click the green play button (▶) that appears next to:
- scenario: - Run a single scenario
From Context Menu¶
- Right-click inside a
.scenariofile - Select Run 'filename.scenario'
From Keyboard¶
| Action | Mac | Windows/Linux |
|---|---|---|
| Run current | Ctrl+Shift+R |
Ctrl+Shift+F10 |
| Debug current | Ctrl+Shift+D |
Ctrl+Shift+F9 |
| Run last | Ctrl+R |
Shift+F10 |
| Debug last | Ctrl+D |
Shift+F9 |
Run Configurations¶
Automatic Creation¶
The plugin automatically creates run configurations when you: - Click a gutter icon - Use Run context menu - Use keyboard shortcuts
Manual Creation¶
- Run → Edit Configurations
- Click + → BerryCrush
- Configure options
- Save
Configuration Options¶
| Option | Description |
|---|---|
| File | .scenario or .fragment file to run |
| Scenario | Specific scenario name (optional) |
| Tags | Filter by tags (e.g., @smoke) |
| OpenAPI | Path to OpenAPI spec |
| Environment | Environment variables |
| Working Directory | Execution directory |
Test Results¶
Run Tool Window¶
After execution, view results in Run tool window:
- ✅ Green check: Test passed
- ❌ Red X: Test failed
- ⏭️ Skip icon: Test skipped
Features¶
- Click test name to jump to source
- View full output in console
- Re-run failed tests only
- Export results
Output Console¶
The console shows: - HTTP requests sent - Response status codes - Assertion results - Variable extractions - Error messages
Debugging¶
Enable Debug Mode¶
- Click the debug icon (🐛) instead of run
- Or use
Ctrl+Shift+D/Ctrl+Shift+F9
Debugging Features¶
- See HTTP request/response bodies
- View variable values
- Step-by-step execution (if configured)
Filtering Tests¶
By Tags¶
Run scenarios with specific tags:
Run command:
By Scenario Name¶
Specify scenario name in run configuration:
- Exact match: Create user
- Pattern: *user*
By File¶
Select specific .scenario file in configuration.
Environment Variables¶
Set environment variables for tests:
- Edit run configuration
- Click Environment variables
- Add key-value pairs
Example:
Access in scenarios:
given base URL is {{env.BASE_URL}}
when I call ^endpoint with header:
| X-API-Key | {{env.API_KEY}} |
Multiple Configurations¶
Create configurations for different environments:
- Local Tests:
BASE_URL=http://localhost:8080 - Staging Tests:
BASE_URL=https://staging.api.com - Production Tests:
BASE_URL=https://api.com
Quick switch between configurations in the toolbar dropdown.
Continuous Testing¶
Auto-Rerun¶
IntelliJ can automatically rerun tests on file save:
- In Run window, click Toggle auto-test
- Tests rerun when files change
Watch Mode¶
Keep test runner active: 1. Run tests 2. Modify scenario file 3. Tests automatically re-execute
Parallel Execution¶
For faster execution (if supported by BerryCrush):
In run configuration: - Set Parallel execution option - Specify number of threads
Troubleshooting¶
Tests Not Starting¶
- Verify BerryCrush library is in classpath
- Check Java SDK is configured
- Ensure file is in test source root
Can't Find Scenarios¶
- Check file extension is
.scenario - Verify file is in indexed directory
- Rebuild project
Connection Errors¶
- Verify target server is running
- Check
BASE_URLconfiguration - Review firewall/proxy settings
Assertion Failures¶
- Click failed assertion to see details
- Review expected vs actual values
- Check JSONPath expressions
Best Practices¶
Organize by Feature¶
src/test/resources/
├── features/
│ ├── user/
│ │ ├── create-user.scenario
│ │ └── delete-user.scenario
│ └── auth/
│ ├── login.scenario
│ └── logout.scenario
└── fragments/
├── auth/
│ └── login-steps.fragment
└── common/
└── setup.fragment
Use Tags Effectively¶
@smoke # Quick validation
@regression # Full test suite
@wip # Work in progress (skip in CI)
@critical # Must-pass tests
Keep Tests Fast¶
- Use fragments for common setup
- Minimize unnecessary API calls
- Clean up test data efficiently