A simple test framework for Nextflow pipelines

written by Lukas Forer and Sebastian Schönherr on March 18, 2022

In our daily work we use Nextflow a lot to analyze our huge datasets derived from clinical trials or from our research in Genetics. As part of nf-gwas, we asked ourselves how to test production ready Nextflow pipelines in an efficient and automated way.

When it comes to testing, nf-core already provides a simple python based test-framework that helps comparing output files of a workflow or process with a list of expected files. Nevertheless, an unit-style testing framework is still missing.

We looked across different Groovy based testing frameworks and discovered Spock. It describes itself as a testing and specification framework and was designed for Groovy and Java applications but it gave us an idea what would be possible using the magic of Power Assertions and a kind of behavioral specifications.

So why not just writing simple test scripts with a when and then block using a DSL language that is as similar as possible to Nextflow and a test-runner that executes these scripts?

nf-test was born: a simple and elegant way to describe the expected behaviour of Nextflow pipelines.

nf-test is still a preview version and the syntax and grammar of the DSL could be changed before we release the first stable version. However, we are using nf-test heavily for our in-house pipelines and we think it could be helpful for the community.

A simple example to test the Hello World Nextflow pipeline would look like this:

If you are interested in nf-test and would give it a try, you can read the documentation, try out this tutorial or simple browse the tests we are using in nf-gwas.

 

Lukas Forer

Lukas is a researcher / software developer and co-leads the Askimed project. His goal is to build efficient and intuitive applications and constantly thinks about smart ways to ...
       

Sebastian Schönherr

Sebastian is a computational biologist and co-leads the Askimed project. He loves working at the intersection between computational genetics and computer science and is involved...