Bruno Testing Framework
Zochil API uses Bruno for API testing and documentation. Bruno collections are stored in the./spec/ folder using the .bru format, providing both API specifications and automated testing capabilities.
Collection Structure
API tests are organized by service and functionality:Environment Configuration
Environment variables are centralized inenvironments/local.bru:
Environment Setup
- Copy the example environment file
- Update variables for your local setup
- Obtain access tokens through authentication endpoints
- Configure service-specific variables as needed
Request Organization
Each API endpoint has a dedicated.bru file with complete HTTP request specification:
Example Bruno Request File
Running Tests
Bruno CLI Installation
Install Bruno CLI globally:Test Execution Commands
Test Structure
Authentication Tests (@auth/)
Authentication tests should be run first to obtain access tokens:
CRUD Operation Tests
Organize tests to follow CRUD patterns:Test Validation
Response Validation
Validate response structure and data:Error Response Testing
Test error scenarios and responses:Test Data Management
Dynamic Test Data
Use variables and scripts for dynamic test data:Test Data Cleanup
Include cleanup scripts in test suites:Continuous Integration
Automated Testing
Integrate Bruno tests in CI/CD pipelines:Test Reporting
Generate test reports for CI systems:Best Practices
Test Organization
- Group related tests in folders
- Use sequential numbering for test execution order
- Include authentication tests at the beginning
- Add cleanup tests at the end
Environment Management
- Use environment variables for all configurable values
- Maintain separate environments for dev/staging/prod
- Never commit sensitive data like passwords or tokens
Data Validation
- Test both success and error scenarios
- Validate response structure and required fields
- Check status codes and error messages
- Test pagination and filtering
Maintenance
- Update tests when API changes
- Remove obsolete test cases
- Keep test data current and relevant
- Document complex test scenarios

