Automated Testing
Set up snapshot-based automated testing for your resolvers
Automated Testing
The test command runs automated snapshot-based tests for your resolvers. Define test cases in test.cyan.yaml with multi-origin file inputs that simulate conflicts from layered templates, then compare the merged output against expected snapshots.
Quick Start
Create Test Configuration
Create test.cyan.yaml in your resolver project root:
tests:- name: json-deep-mergeexpected:type: snapshotvalue:path: ./snapshots/json-deep-mergeconfig: {}resolver_inputs:- path: ./inputs/template-aorigin:template: template-alayer: 0- path: ./inputs/template-borigin:template: template-blayer: 1
Create Input Fixtures
Create directories for each template origin with conflicting files:
mkdir -p inputs/template-a inputs/template-b
Each directory should contain the files that template would produce, creating a conflict scenario for your resolver.
Run Tests
cyanprint test resolver .
On the first run, use --update-snapshots to generate initial expected output:
cyanprint test resolver . --update-snapshots
Understanding test.cyan.yaml
Each test case defines multi-origin inputs and expected merged output:
tests:- name: three-way-mergeexpected:type: snapshotvalue:path: ./snapshots/three-way-mergeconfig:strategy: deepresolver_inputs:- path: ./inputs/baseorigin:template: base-templatelayer: 0- path: ./inputs/feature-aorigin:template: feature-alayer: 1- path: ./inputs/feature-borigin:template: feature-blayer: 2
Fields
| Field | Required | Description |
|---|---|---|
name | Yes | Unique test case identifier |
expected | Yes | Snapshot path or inline expected value |
resolver_inputs | Yes | List of file sets from different template origins |
config | No | Runtime configuration passed to the resolver |
Resolver Inputs
Each entry in resolver_inputs represents files from a specific template:
| Field | Description |
|---|---|
path | Directory containing files from this template |
origin.template | Template identifier this file set came from |
origin.layer | Layer index in composition order (0 = base, higher = overlay) |
The layer ordering determines conflict resolution priority — higher layers overlay lower layers, matching how layered template composition works in production.
Project Structure
Running Tests
# Run all testscyanprint test resolver .# Run a specific testcyanprint test resolver . --test json-deep-merge# Run in parallelcyanprint test resolver . --parallel 4# Update snapshots after intentional changescyanprint test resolver . --update-snapshots
When using --update-snapshots, resolver tests run sequentially regardless of the --parallel flag to ensure consistent snapshot generation.
Snapshot Comparison Rules
| File Type | Comparison Method |
|---|---|
.json files | Deep comparison (field order ignored) |
| Other text files | Exact string match (trailing whitespace trimmed) |
| Binary files | Skipped (reported but not compared) |
CI/CD Integration
cyanprint test resolver . --junit test-results.xml --disable-daemon-autostart
Next Steps
- CLI Commands Reference — Full command options and flags
- Push to Registry — Publish your resolver