Test and Validate
This guide explains how to test and validate a new or existing connector to ensure it functions correctly before deployment.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 local deployment