Migrating from pytest to nf-test
Checkout a new branch for your module/subworkflow tests.
To create the necessary files for nf-test and ensure a smooth transition, we will use the template provided by nf-core/tools.
Here are the steps to follow:
-
Use nf-core/tools to migrate the module/subworkflow with
--migrate-pytest
.Technical detailsThis command will:
-
rename the current module directory to
<module>_old
to avoid conflicts with the new module, -
create a new module named
<module>
, based on the nf-test template. -
copy the
main.nf
,meta.yml
andenvironment.yml
files over to preserve the original module code. -
(optional) If your module has a
nextflow.config
file to run (e.g. forext.args
specification), the command will also copy it to the module’stests/
directory and the path will be added to themain.nf.test
file.
Technical detailsThis command will:
- rename the current subworkflow directory to
<subworkflow>_old
to avoid conflicts with the new subworkflow, - create a new subworkflow named
<subworkflow>
based on the nf-test template. - copy the
main.nf
andmeta.yml
files over to preserve the original subworkflow code.
-
-
You will then be asked if you want to delete the old files or keep them. No worries, we will print the content of the old pytests in the terminal so you can copy the information to the new nf-test files.
-
Copy the inputs from the pytests and provide them as positional inputs
input[0]
in themain.nf.test
file -
Follow the steps in the tutorial for writing nf-tests to update the contents of the
main.nf.test
file with the information from the pytest tests. -
Create the snapshot of your test with the following command.
-
If you chose to not remove the old module directory with nf-core/tools:
- Remove the corresponding tags from
tests/config/pytest_modules.yml
so that py-tests for the module/subworkflow will be skipped during GitHub CI.
- Remove the corresponding pytest files in
tests/modules/nf-core
- Remove the old module
- Check if everything is according to the nf-core guidelines with:
- Remove the corresponding pytest files in
tests/subworkflows/nf-core
- Remove the old subworkflow
- Check if everything is according to the nf-core guidelines with:
- Remove the corresponding tags from
-
create a PR on the nf-core/modules repo and add the
nf-test
label to it.