Testing Guide
nf-bids uses a four-layer test strategy that builds from fast unit tests to full BIDS dataset validation and documentation verification. Each layer has a clear gate: a failure in an earlier layer should be fixed before moving to the next.
Before running any tests, complete Building & Installation. After fixing bugs, proceed to the Release Guide. See Performance Benchmark for information on benchmarking the closure-based operators.
Layer 1 — Unit Tests (Spock / JUnit)
Unit tests live under src/test/groovy/nfneuro/ and cover the plugin’s
individual classes in isolation using the
Spock Framework.
Test Classes
| Class | What it covers |
|---|---|
|
Flat-output format: |
|
YAML config loading, reserved-key ( |
|
Multiple configs sharing the same |
|
|
|
|
|
|
|
|
|
Multi-field composite key construction and equality |
|
Closure-based key extractor — type safety, null handling |
|
Plugin extension registration; operator availability on |
Evidence / Failure Signals
Passing: All unit tests succeed in under a minute.
Test reports appear at build/reports/tests/test/index.html — open in a
browser for per-test detail.
Failing: A unit test failure means core logic is broken. The stack trace in the Gradle output points directly to the failing assertion. Do not proceed to integration tests while unit tests are red — the integration suite will also fail and you will lose diagnostic resolution.
To run a single test class:
./gradlew test --tests nfneuro.plugin.channel.BidsHandlerFlattenSpec
Layer 2 — Integration / Validation Tests (nf-test)
Integration tests live under test/validation/ and use
nf-test to run the full plugin against real BIDS
example datasets.
nf-test.config configures the suite:
config {
testsDir "test/validation"
workDir ".nf-test"
configFile "nextflow.config"
profile ""
}
Run the Full Integration Suite
From the repository root:
nf-test test test/validation/
Preferred wrapper (ensures plugin/bootstrap consistency with CI):
cd test/validation
bash test_datasets.sh
Test Suites
| Suite file | Datasets / scenario |
|---|---|
|
Plain-set subjects (single file per suffix); baseline comparison |
|
Named sets (entity-based dimensions, e.g. |
|
Sequential sets (ordered echo/flip arrays); baseline comparison |
|
Mixed sets (nested grouping + sequencing, e.g. |
|
Custom datasets not in bids-examples; edge-of-spec scenarios |
|
Multiple configs sharing the same BIDS suffix ( |
|
Flat output format: |
Update Snapshots
nf-test compares channel output against committed snapshot files
(*.nf.test.snap).
If you intentionally changed the output shape of a test, regenerate its
snapshot, then re-run the full suite to ensure no other test regressed:
# Regenerate snapshot for a specific suite
nf-test test test/validation/comparison_plain_sets.nf.test --update-snapshot
# Then run the full suite to check for regressions
nf-test test test/validation/
Or regenerate through the project wrapper:
cd test/validation
bash test_datasets.sh --update-snapshots
Never run --update-snapshot across the full suite unless you have
intentionally changed behaviour in all suites. Doing so silently accepts
regressions.
|
Evidence / Failure Signals
Passing: All 25+ test cases succeed. The suite exercises 18 BIDS datasets achieving 100% baseline alignment (see Performance Benchmark).
Failing: A mismatch between the test output and the snapshot means the plugin emits different data than expected. Check whether the change was intentional (update snapshot) or a regression (fix the code). Do not merge a branch with integration failures.
Layer 3 — Edge Cases and Benchmarks
Edge Case Tests
Edge case tests are in test/edge_cases/ and target operator
behaviour at the boundaries: large items, many items, missing fields,
concurrent execution, and complex joins.
Run with nf-test:
nf-test test test/edge_cases/
Or run all edge-case workflows directly (useful for interactive inspection of
NF_WORK output):
cd test/edge_cases
./run_all_tests.sh
Individual edge-case workflows:
| Workflow | Scenario |
|---|---|
|
Single items with very large payloads |
|
High item count (10 000+) stress test |
|
Deeply nested maps as items |
|
Items with absent optional keys |
|
Concurrent operator execution (thread-safety) |
|
|
|
|
|
|
Evidence: Edge-case failures surface operator-level thread-safety or boundary bugs that the main nf-test suite does not trigger. A failure here should be fixed before releasing.
Performance Benchmarks
Benchmark workflows live in test/benchmark/ and compare each
closure-based operator against its Nextflow built-in counterpart.
cd test/benchmark
nextflow run benchmark_grouptuple.nf
nextflow run benchmark_join.nf
nextflow run benchmark_combine.nf
nextflow run benchmark_combineby_new.nf
Evidence: Timing output is printed to stdout. Expected overhead is 10–30 ms per operator for typical BIDS datasets. See Performance Benchmark for the reference numbers and the analysis. Benchmark regressions (sustained increases >50 %) should be investigated before release.
Local CI Reproduction with act
Layer 4 — Documentation Build Verification
The documentation site (./gradlew docs) is itself a build artefact
that must succeed before a release.
Build the Documentation
From the repository root:
./gradlew docs
# or equivalently:
make docs
This runs three steps in sequence:
-
apiDocs— generates GroovyDoc fromsrc/main/groovy/ -
buildDocsSite— renders PlantUML diagrams and builds the Antora site -
integrateApiDocs— copies the GroovyDoc intodocumentation/build/site/
The finished site lands at documentation/build/site/.
Render Only the Diagrams
./gradlew renderDiagrams
# or:
make docs-diagrams
Evidence: A successful ./gradlew docs run with no warnings confirms:
broken cross-references (xref:) are caught by Antora, all PlantUML
diagrams render to SVG, and the GroovyDoc is wired into the site.
Failure mode: Antora aborts on unresolved page references or malformed
AsciiDoc; PlantUML aborts if dot (Graphviz) is missing from the PATH.
Check the Prerequisites section
for Graphviz and Node.js requirements.