Testing Guide
Tiered testing approach for different development phases and resources.
Quick Commands
Development (Python-only)
make test-dev # Fast marker-based tests (1,788 tests, ~36s) for iteration
make test # Full pytest run on host (~2min, may include skips)
make lint # Ruff + mypy checks (~5s warm, ~30s cold mypy cache)
make format # Auto-format & autofix style issues
make check # format + test-dev (mutating quick gate)
Timings below are measured on a 10-core arm64 laptop with warm caches (uv, mypy,
docs/_build, and a currentsirnaforge:latest). They were previously inherited from a 30-test suite and were wrong by up to 9x; if you change a tier’s population, re-measure rather than editing the number.
Note:
make checkrunsmake formatfirst, so it will modify files to enforce style before executing tests.
Docker (Full environment)
make docker-build # Build Docker image
make docker-build-test # and test
make docker-shell # Interactive debugging
Test Categories by Tier
Target |
Purpose |
Time |
Scope |
Resources |
|---|---|---|---|---|
|
Fast development iteration (pytest |
~36s |
1,788 tests — unit-style, hermetic |
Minimal |
|
CI/CD smoke with coverage |
~13s |
40 |
Low |
|
Host + container validation with combined coverage |
~6.5min |
1,822 host + 46 container, merged coverage |
Medium |
|
Full pytest run (allows skips/failures) |
~2min |
Entire 1,868-test suite on host |
Medium |
|
Explicit local-only live-service checks |
Varies |
|
Low |
|
Nextflow-specific subset |
2 tests |
|
Medium |
|
Container-only tests ( |
~4.7min |
tests/container suite |
High |
test-release also pays a rebuild whenever the image is stale, because docker-ensure rebuilds when
sirnaforge:latest was built from a different version or a different source fingerprint. Two very
different costs hide behind that:
Source-only change (anything under
src/, which is the usual case): ~3 minutes. The conda and bioinformatics-tool layers are cache hits; only theCOPY srclayers and the export re-run. Measured at 3m11s.Cold cache (no Docker layer cache, changed
Dockerfile, changeduv.lock): 15-20 minutes, because the tool stack is rebuilt.
So a full make test-release after an ordinary source edit is ~9.5 minutes, not ~25. The two
requires_* subsets are sized in tests rather than seconds because both skip entirely without the
capability, and neither is a meaningful timing.
There is no test-requires-docker target. -m requires_docker matches nothing, and pytest exits 0
on a fully deselected run, so the target was green over an empty set — the worst possible thing to
read during release triage. The marker stays declared for the day a host-side Docker test exists.
Environment Requirement Markers
Three markers describe an environment a test cannot create for itself, and tests/conftest.py
skips rather than fails when it is absent. The shared principle: each probe asks whether the
dependency works, not whether it is nominally present — a resolvable hostname and an
executable on PATH both lie.
runs_in_container— skipped unless the interpreter is genuinely inside a container (Docker’s/.dockerenvor Podman’s/run/.containerenv). These tests need the image’s bioinformatics tooling (bwa-mem2,RNAfold, Nextflow), so run them withmake docker-test. On the host they are expected to skip;make test-ciandmake test-release-hostfilter them out entirely.requires_nextflow— skipped unlessnextflow -versionactually exits 0. The launcher onPATHis only a shim that fetches the framework JAR intoNXF_HOMEon first use, soshutil.which("nextflow")returns a path even on an image where no real invocation can succeed. This probe mirrorsNextflowRunner.validate_installation, so a test skips exactly when the pipeline itself would reportnextflow_unavailable. Inside the image,test_nextflow_availableseparately fails if this required runtime cannot start. The Docker build also runsnextflow -versionwith networking disabled, after pip installation, to verify that the launcher matches the bundled framework JAR.requires_network— local-only and skipped by default, even when the internet works. Usemake test-requires-networkoruv run pytest --run-network -m requires_networkto opt in. CI rejects--run-network; normal CI and both release stages explicitly exclude this marker. A default run skips before attempting any live-service probe. With local opt-in, a verified TLS handshake withrest.ensembl.orgmust still succeed. The probe uses Python’s own trust store; a successful handshake does not guarantee the remote API will be healthy. Actual client failures remain failures in these deliberate local runs.
What each test-release stage is actually for
test-release is docs, then the host suite, then the container suite, then a coverage rollup.
The two test stages answer different questions and are not interchangeable:
Host stage — every
dev/ci/releasetest that is notruns_in_container, serial, with coverage. 1,822 selected, ~83s. This is where line coverage comes from: 83% overall, and 90-100% on everything 0.7.1 added. It reaches that number with the screen stubbed and Nextflow monkeypatched.Container stage — 46 tests that drive the installed CLI with
subprocess.runinside the image, ~4.7min. It answers “does the artifact work”, which coverage cannot measure: coverage does not follow a subprocess, so these tests contribute 0% of the new modules to the rollup while genuinely executing them. That is expected. Do not plumbCOVERAGE_PROCESS_STARTinto the container to raise the number — it would tell you nothing the host stage has not already said. Assert the artifacts instead (tests/container/release_artifacts.py), which is how the tier distinguishes “screened clean” from “never screened”.
Expect 7 of the 46 container tests to skip without a verified TLS route: the TP53 full workflow, the five variant/SNP modes and the gene-symbol search. The custom-transcriptome test uses the checked-in human GRCh38 chromosome 21 cDNA reference (provenance and regeneration), builds a fresh index and requires completed transcriptome evidence. It needs no full-transcriptome download or index build. The network tests exercise live retrieval, so a green container stage on a proxied network is a statement about the packaged artifact and the toy-reference screen, not about the gene name → Ensembl → transcripts → screen path.
The container stage is the only place the report (#103), the .nf evidence emission (#100) and the
installed benchmark/report commands run for real, so it is the only place a packaging or
integration defect in them can be caught. workflow.py turns a failed render and a failed manifest
write into logger.warning, so the CLI exits 0 either way: the assertions in
release_artifacts.py are what make those failures visible.
Do not trust the coverage number if anything else touched this working tree. There are two independent ways to get a wrong percentage, and the second is the one that actually bites.
A second writer.
[tool.coverage.run] data_fileis the fixed path.coverage, andmake test-ci, a bareuv run pytest --covand the container stage’s--cov-appendall write it. A concurrent run in the same checkout rewrites the host stage’s data between step 1 and step 3.A source edit between measurement and report.
coverage reportstores bare line numbers and re-parses the source file when it renders, so an edit landing after step 1 makes the recorded lines land on the wrong statements. Measured on this repository: the rollup printed 83% withworkflow.pyat 87%, and re-reading the same, untouched.coveragetwelve minutes later printed 78% withworkflow.pyat 56% — one concurrent commit to that file, no test re-run, no change to the database. Only the edited file drifted; every other module read identically.Test counts are unaffected either way, because each pytest run reports its own. If the total looks wrong, re-run
make test-release-hoston a quiescent tree and report on that, and setCOVERAGE_FILEto a scratch path for anything else that needs coverage meanwhile.
A dev test must never reach the network
An unmarked test that calls out is worse than a slow test: it passes or fails on the environment. The two ways it has happened here, both fixed, both cheap to reintroduce:
Orthology.
_process_nextflow_resultsresolves cross-species orthologues through Ensembl Compara whenever a screen declares more than one species and a hit row comes from a non-query species. Behind a TLS-intercepting proxy each call cost ~25s — three attempts per route with 2s + 4s backoff — and 20 tests paid it, which was 90% of thedevtier. SetWorkflowConfig(ortholog_mapping_file=...)to state the orthologues in a file instead (tests/unit/data/ortholog_mapping_synthetic.jsonis the fixture); that is also the supported air-gapped path for a real run.Nextflow. Driving
step5_offtarget_analysisruns a realnextflow run -profile docker, whose failure step 5 swallows — so the test still passes, 23s later. MonkeypatchSiRNAWorkflow._run_nextflow_offtarget_analysisunless the test is markedrequires_nextflow.
make test-dev should stay under ~45s with no test above ~3s; -m dev --durations=10 is the check.
The old wording said 30s and 2s, and both clauses had quietly gone false — the tier grew from 30 tests to 1,788 while the numbers stayed. A tripwire that is already tripped is one nobody reads, so these are re-baselined against measurement: 1,788 tests in ~36s on a 10-core laptop, slowest item 2.27s. Both ceilings were re-checked after the release run, at load average 13 with another session working in the same checkout: 36.22s, slowest 2.27s — so the headroom is real and not an idle-machine artifact. Expect up to 2-3x on a badly contended machine (the same tests have been measured at 54s and 6.1s). If a change pushes either past its ceiling, the question to ask is whether a test acquired a dependency — those two failure modes are documented above and both have happened.
Do not read the host stage’s --durations as this ceiling. Under coverage and -n 0 the same slowest
test measures 5.1s rather than 2.27s; that is instrumentation, not a regression.
Running network tests behind a TLS-intercepting proxy
Corporate proxies (Zscaler, Netskope and similar) re-sign HTTPS with a private root that lives
in the OS keychain, which Python and aiohttp do not read — so requires_network tests skip
even though curl works. Point Python at a bundle that includes that root:
# macOS: append the keychain's proxy root to the system bundle
cat /etc/ssl/cert.pem > /tmp/sf_ca_bundle.pem
security find-certificate -a -c Zscaler -p /Library/Keychains/System.keychain >> /tmp/sf_ca_bundle.pem
SSL_CERT_FILE=/tmp/sf_ca_bundle.pem make test-requires-network
Export SSL_CERT_FILE (and REQUESTS_CA_BUNDLE for requests-based tooling) in your shell
profile to make this permanent. Substitute your provider’s certificate name for Zscaler.
Local Development Testing
1. Initial Setup (Required - Run Once)
# Install all development dependencies
make dev
# Expected: 60-120 seconds, installs deps + pre-commit hooks
# ✅ Success indicator: "Ready for development!"
2. Fast Iteration Cycle
# Fastest validation (recommended for active development)
make test-dev
# Expected: ~36 seconds, 1,788 tests
# ✅ Success: All tests pass, no Docker and no network required
3. Code Quality Checks
# Quick linting (fast)
make lint
# Expected: ~5 seconds
# Tools: ruff check, ruff format --check, mypy
# Auto-fix linting issues
make format
# Expected: ~5-10 seconds, auto-fixes code style issues
# Combined quality + fast tests
make check
# Expected: ~45 seconds, runs format + lint + test-dev
4. Pre-Commit Validation
# Run CI-tier tests (quick smoke tests for CI/CD)
make test-ci
# Expected: ~13 seconds, 40 tests
# Includes smoke tests with coverage reports
# Note: this is the historical PR gate and it selects no test added in 0.7.1;
# `make test-dev` now runs alongside it in CI for exactly that reason.
# Full release validation
make test-release
# Expected: ~6.5 minutes -- docs (~20s), host suite serial (~83s), container suite (~4.7min),
# coverage rollup (~6s). Add ~3 minutes for a source-only image rebuild, or 15-20
# on a cold Docker cache. Measured end to end at 9m38s including a source rebuild.
# Note: exactly 15 tests skip without a verified TLS route -- 7 host, 8 container (Ensembl,
# miRBase); that is honest,
# and the whole gene-name -> Ensembl -> off-target path is what goes untested with them.
# Full local test suite (all tests, may have skips/failures)
make test
# Expected: ~2 minutes, 1,868 tests, includes all test categories
# Note: the 46 container tests skip on the host by design (`runs_in_container`)
Docker Testing (Comprehensive Validation)
Prerequisites
Docker installed and running
4GB+ RAM available to Docker
Image built with:
make docker-build
1. Build Docker Image
make docker-build
# Expected: ~15-20 minutes first time, creates sirnaforge:latest
# ✅ Success: "Docker image: sirnaforge:latest"
# Image size: ~2.5GB (includes all bioinformatics tools)
2. Run Tests in Container
# Run tests INSIDE Docker container (validates image setup)
make docker-test
# Expected: ~4.7 minutes (46 tests, 8 of them skipping without Ensembl; rebuilds a stale image first)
# Tests all container-based functionality
# ✅ Success: All tests pass, verifying Docker environment
# Enter interactive shell for debugging
make docker-shell
# Expected: Interactive bash prompt inside container
# Useful for: Debugging, manual testing, tool validation
3. Manual Docker Verification
Basic Functionality
# Version check
docker run --rm sirnaforge:latest sirnaforge version
# Expected output: Version information
# Help system
docker run --rm sirnaforge:latest sirnaforge --help
docker run --rm sirnaforge:latest sirnaforge design --help
Workflow Testing
# Test with sample data
docker run --rm -v $(pwd)/examples:/data sirnaforge:latest \
sirnaforge design /data/sample_transcripts.fasta \
-o /tmp/results.csv --top-n 5
# Expected: Results file created with siRNA candidates
Best Practices
Development Workflow
Setup once:
make devFast iteration:
make test-devafter changesQuality check:
make lintbefore commitsPre-commit:
make checkbefore pushingValidation:
make test-releasebefore releases
Resource Management
Local development: Use
test-devfor iteration andtestbefore commitsCI/CD: Use
test-ciwith artifactsRelease validation: Use
test-releasewith full coverageQuick validation: Use
make checkfor lint + fast tests
ZFN Manual Validation
EXPERIMENTAL — software checks do not establish biological validity. The engineering defects tracked in #82 have been addressed with regression coverage, including real-reference on-target recovery and the public Nextflow route. Historical backend runs used the published CCR5 right half-site text in the wrong orientation and do not establish on-target recovery. The current real-reference runbooks use
--zfn-right-half-site CTTTTGCAGTTT, the model-oriented reverse complement of the publishedAAACTGCAAAAG. Require independent genomic and experimental validation before using ZFN output for decisions. Require independent validation before sign-off.
The heavy ZFN benchmarking and real-reference checks are documented as technical validation notes rather than notebook-management policy.
use zfn_backend_tuning.md for the backend selection rationale — runtime ordering only, per the caveat above
use zfn_hg38_primary_test_commands.md for full hg38 primary reruns and the expected GRCh38 on-target locus
keep chr3 and hg38 durable behavior in
tests/integration/so reference resolution, search execution, and annotation are exercised togetherwhen adding ZFN half-site fixtures, retain the source publication’s sequence and orientation explicitly, then verify the model-oriented queries recover the pinned GRCh38 site.
miRNA default-backend rollout validation
Use this sequence when touching the internal miRNA backend seam or the Nextflow batch path.
The operational default for miRNA seed analysis is pyahocorasick.
Keep exhaustive_python as the correctness oracle for parity checks and treat the BWA path as the semantic comparison baseline in environments where BWA exists.
Backend selection remains intentionally internal for this slice; do not add a public CLI or workflow knob unless the product surface is being widened on purpose.
make lint
docker run --rm \
-v $(pwd):/workspace \
-w /workspace \
-v ~/.cache/sirnaforge:/home/sirnauser/.cache/sirnaforge \
-e CI \
-e GITHUB_ACTIONS \
-e PYTEST_ADDOPTS= \
-e SIRNAFORGE_CACHE_DIR=/home/sirnauser/.cache/sirnaforge \
-e NXF_HOME=/home/sirnauser/.cache/sirnaforge/nextflow/home \
sirnaforge:latest \
bash -lc 'export PYTHONPATH=/workspace/.pip:/workspace/src && /opt/conda/bin/python -m pytest -n 0 -v \
tests/container/test_toy_databases_integration.py::test_toy_mirna_seed_backend_matches_bwa_semantic_hits \
tests/container/test_workflow_modes.py::test_nextflow_mirna_batch_path_uses_default_backend \
--override-ini="addopts=-ra -q --strict-markers --strict-config --color=yes"'
Treat the default backend as rollout-ready only when all of the following hold:
tests/unit/test_mirna_seed_backends.pycontinues to protect exhaustive-oracle parity and schema compatibilitytest_toy_mirna_seed_backend_matches_bwa_semantic_hitspasses in the container environmenttest_nextflow_mirna_batch_path_uses_default_backendpasses and emits aggregated miRNA artifacts through the embedded Nextflow pathno new public CLI or workflow backend-selection surface is introduced
Timeouts and Expectations
Never cancel
uv sync --dev(can take 60-120s first time)Docker builds take ~15-20 minutes first time, much faster subsequently.
docker-ensuretriggers one wheneversrc/,pyproject.toml,uv.lockor the Dockerfile has changed since the image was built, somake test-releaseafter a source edit pays that cost once.make test-devshould complete in ~36s (1,788 tests) — see the ceiling abovemake test-cicompletes in ~13s (40 tests) and writes coverage.xmlmake test-releasecompletes in ~6.5 minutes when the image is current, ~9.5 with a source rebuild
Quick Health Checks
# Local installation verification
uv run sirnaforge version
uv run sirnaforge design examples/sample_transcripts.fasta -o /tmp/test.csv
# Docker environment verification
docker run --rm sirnaforge:latest sirnaforge version
📋 For Docker operations and deployment: See the Docker documentation in the docker/ directory
This guide focuses on testing workflows across development phases and CI/CD environments.
Reproduce a small Docker CI runner
make docker-test DOCKER_TEST_RESOURCE_FLAGS="--cpus=4 --memory=8g --memory-swap=8g"
The dev-image workflow uses these limits on pushes and relevant pull requests against dev.
Pull requests build and test locally in CI; registry login and image publication run only for
non-PR events. The CPU quota is deliberate: affinity can still expose
the host’s full CPU set while Nextflow sees only four processors. Reference indexing and alignment
must complete using automatic resource detection; no test-only max_cpus override is supplied.
The container gate exercises variant CLI integration with synthetic cached records and a local transcript FASTA, including avoid/target/both modes and repeated coordinate inputs. These fixtures validate integration and reporting, not allele-specific biological performance. Live TP53 and rsID service checks are retained separately:
uv run pytest tests/integration/test_variant_live.py --run-network -v
Those tests require working Ensembl/NCBI endpoints, not just a successful TLS handshake. The
make docker-test image gate excludes every requires_network test by default, including the
legacy full-TP53 smoke; its real indexing/alignment coverage uses the chromosome 21 fixture.
To explicitly include live container checks on a local machine, run:
make docker-test DOCKER_TEST_MARKERS=runs_in_container DOCKER_TEST_PYTEST_ARGS=--run-network
The container inherits CI flags, so this opt-in is rejected in CI as well. The host and container
release gates always exclude live tests; ordinary make test also skips them unless explicitly
opted in. The deterministic cached-variant tests remain part of container release validation.
Remote failures include both captured stdout and stderr.