Skip to main content

Testing Guide

Testing guidelines and best practices for Qarion ETL.

Test Structure

Tests are organized in the tests/ directory:

tests/
├── test_flows.py
├── test_engines.py
├── test_code_generators.py
└── ...

Writing Tests

Unit Tests

Test individual components in isolation:

import pytest
from qarion_etl.flows.base import FlowPlugin

def test_flow_plugin_generate_datasets():
"""Test dataset generation."""
plugin = MyFlowPlugin()
flow_def = {...}
datasets = plugin.generate_datasets(flow_def)
assert len(datasets) > 0

Integration Tests

Test component interactions:

def test_flow_execution():
"""Test complete flow execution."""
# Setup
# Execute
# Assert
pass

Test Fixtures

Use pytest fixtures for common setup:

@pytest.fixture
def sample_flow():
return {
'id': 'test_flow',
'flow_type': 'change_feed',
# ...
}

Running Tests

# Run all tests
pytest

# Run specific test file
pytest tests/test_flows.py

# Run with coverage
pytest --cov=qarion-etl --cov-report=html

# Run with verbose output
pytest -v

Test Coverage

Maintain high test coverage:

  • Core logic: 90%+
  • Plugins: 85%+
  • Utilities: 80%+

Best Practices

  1. Test edge cases: Empty inputs, None values, invalid data
  2. Test error handling: Exception cases
  3. Use descriptive names: test_function_name_scenario
  4. Keep tests focused: One assertion per test when possible
  5. Mock external dependencies: Database, file system, etc.