Philosophy of nf-tests for nf-core components
- Each component contains a
tests/
folder beside themain.nf
of the component itself, containing the test files. - Test files come with a snapshot of component output channels.
nf-test guidelines for a simple un-chained module
- Some modules MAY require additional parameters added to the test command to successfully run. These can be specified using a params input and an
ext.args
variable within the process scope of thenextflow.config
file that exists alongside the test files themselves (and is automatically loaded when the test workflowmain.nf
is executed).
If your module requires a nextflow.config
file to run, create the file to the module’s tests/
directory and add the following code to use parameters defined in the when
scope of the test.
You do not need to modify the contents of this file any further.
Then add the config to the main.nf.test
file.
Lastly supply the params in the when section of the test.
-
When your test data is too big, the tests take too long or require too much resources, you can opt to run your tests in stub mode by adding the following option:
Notethis can be added at the top of
main.nf.test
to have all tests run in stub mode or this can also be added to a single test
See the assertions documentation for examples on how to handle different types of test data and scenarios.
nf-test guidelines for a chained module
-
For modules that involve running more than one process to generate required test-data (aka chained modules), nf-test provides a setup method.
-
For example, the module
abricate/summary
requires the processabricate/run
to be run prior and takes its output as input. Thesetup
method is to be declared before the primarywhen
block in the test file as shown below:
The setup method can run more than one process each enclosed in their own run
block
- Then, the output of setup process/es can be provided as input in the
process
section ofwhen
block
- Next, in the
then
block we can write our assertions that are used to verify the test. A test can have multiple assertions but, we recommend enclosing all assertions in aassertAll()
block as shown below:
- the
main.nf.test
file for chained modules will finally look as shown below: