> ## Documentation Index
> Fetch the complete documentation index at: https://doc.blueapi.ir/llms.txt
> Use this file to discover all available pages before exploring further.

# EMEP Unit Test Plan Per Component

> Unit test coverage targets and test categories for every EMEP component from ModelRegistry to DeploymentManager.

Unit tests cover every EMEP component in isolation. Each component has a coverage target, a list of critical test categories, and a defined mock strategy for external dependencies.

## Coverage Table

| Component | Coverage Target | Critical Test Categories | Mock Strategy |
| - | - | - | - |
| ModelRegistry | 90% | CRUD, lifecycle transitions, search, concurrency | In-memory DB |
| ModelLoader | 85% | Format parsing, checkpoint loading, error handling | Mock filesystem |
| ModelCompatibilityAnalyzer | 90% | Tensor shape validation, tokenizer compatibility, architecture compatibility, state transitions | Mock ModelRegistry |
| TensorEngine | 85% | Element-wise ops, broadcasting, dtype coercion, shape mismatch | CPU-only backend |
| MergeEngine | 85% | Strategy dispatch, parameter validation, artifact storage | Mock TensorEngine, Mock ArtifactStore |
| MergeStrategy | 90% | SLERP, TIES, DARE, Task Arithmetic, Franken-Merge correctness | Fixed random seeds |
| CandidateGenerator | 80% | Genome encoding, decoding, validation | Mock MergeEngine |
| EvolutionEngine | 80% | NSGA-II, NSGA-III, CMA-ES loop correctness | Mock CandidateGenerator, Mock FitnessEngine |
| EvaluationEngine | 85% | Benchmark dispatch, result aggregation, timeout handling | Mock BenchmarkEngine |
| BenchmarkEngine | 85% | Harness execution, seed control, backend switching | Mock InferenceBackend |
| FitnessEngine | 80% | Objective computation, normalization, multi-objective aggregation | Mock EvaluationEngine |
| ExperimentTracker | 85% | State transitions, schema validation, query | In-memory store |
| ArtifactStore | 80% | Upload, download, signing, encryption, retention | Mock S3 / local filesystem |
| DatasetRegistry | 80% | Split management, format validation, caching | Mock filesystem |
| QuantizationEngine | 85% | NF4, INT8, FP8 quantization and dequantization | CPU-only |
| InferenceBackend | 80% | Load, forward, batching, unload | Mock GPU layer |
| DeploymentManager | 75% | Promotion, rollback, stage validation | Mock ArtifactStore |

## Test Patterns

### Lifecycle Transition Tests

For every component with state machines (ModelRegistry, ExperimentTracker), unit tests verify all valid transitions and reject invalid ones. Example: a model cannot transition from DISCOVERED directly to PROMOTED.

### Error Path Tests

Every public method must have tests for:

* Null or missing required arguments
* Invalid enum values
* Resource not found
* Timeout or resource exhaustion
* Concurrent modification

### Determinism Tests

MergeStrategy and TensorEngine tests use fixed random seeds and compare outputs against golden values. Any nondeterminism is treated as a bug.

## Mock Strategy

External dependencies are mocked at the interface boundary. Mocks are validated against the real implementation in integration tests. Mock contracts are documented in the component's test directory.

## Integration Points

* **CI**: unit tests run on every commit.
* **Coverage**: coverage reports are uploaded to ArtifactStore and tracked in ExperimentTracker.
* **Numerical Testing**: unit tests for TensorEngine and MergeStrategy reference tolerance thresholds defined in [Numerical Testing](https://doc.blueapi.ir/testing/numerical-testing.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.