Testing overview
Unit tests
Test individual components and routes in isolation
Integration tests
Test connector interactions with external services
Contract tests
Validate API contracts and OpenAPI specifications
End-to-end tests
Test complete flows from request to response
Run unit tests
Unit tests are supported within connectors through the camel-test-junit5 library. This test library is available for every connector from thegrandcentral-bom.
Running tests with maven
Execute unit tests using Maven:Running specific tests
Run a specific test class:Unit test examples
For comprehensive unit test examples, see the Grand Central connector template repository.Example: Basic route test
Example: Mock external service
Test configuration
Test properties
Configure test-specific properties insrc/test/resources/application.properties:
Test profiles
Create custom test profiles for different scenarios:Integration testing
Wiremock for external services
Use WireMock to mock external HTTP services:API contract validation
OpenAPI specification validation
Validate that your connector implementation matches the OpenAPI specification:Test coverage
Generate coverage reports
Generate test coverage reports with JaCoCo:target/site/jacoco/index.html.
Coverage goals
Aim for the following coverage targets:- Line Coverage: Minimum 80%
- Branch Coverage: Minimum 75%
- Method Coverage: Minimum 85%
Performance testing
Load testing with Gatling
Run performance tests to validate connector behavior under load:Continuous testing
Running tests in CI/CD
Include tests in your CI/CD pipeline:Validation checklist
Before deploying your connector, ensure:Unit tests
Unit tests
- All unit tests pass
- Coverage meets minimum thresholds
- Edge cases are covered
Integration tests
Integration tests
- External service interactions are tested
- Error scenarios are validated
- Timeouts and retries work correctly
Contract validation
Contract validation
- OpenAPI specification is valid
- Request/response schemas match
- All endpoints are documented
Performance
Performance
- Load tests pass successfully
- Response times are acceptable
- Resource usage is within limits
Troubleshooting tests
Common issues
Tests fail locally but pass in CI
Tests fail locally but pass in CI
Check for environment-specific configurations or dependencies
Flaky tests
Flaky tests
- Add proper wait conditions
- Avoid time-based assertions
- Use deterministic test data
Slow test execution
Slow test execution
- Parallelize test execution
- Use test profiles to skip heavy tests during development
- Optimize test setup and teardown
Next steps
After successfully testing your connector:- Configure your connector for deployment
- Review code standards
- Proceed to deployment