Skip to content

Workflow Testing

nf-test also allows to test a specific workflow. Please checkout the CLI to generate a workflow test.


nextflow_workflow {

    name "<NAME>"
    script "<PATH/TO/>"
    workflow "<WORKFLOW_NAME>"

    test("<TEST_NAME>") {


💡 Script paths that start with ./ or ../ are considered relative paths. These paths are resolved based on the location of the test script. Relative paths are beneficial when you want to reference files or directories located within the same directory as your test script or in a parent directory. These paths provide a convenient way to access files without specifying the entire path.


The workflow object can be used in asserts to check its status, error messages or traces.

// workflow status
assert workflow.success
assert workflow.failed
assert workflow.exitStatus == 0

// workflow error message
assert workflow.errorReport.contains("....")

// trace
//returns a list containing succeeded tasks
assert workflow.trace.succeeded().size() == 3

//returns a list containing failed tasks
assert workflow.trace.failed().size() == 0

//returns a list containing all tasks
assert workflow.trace.tasks().size() == 3

//returns a list containing all lines from stdout
assert workflow.stdout.contains("Hello World") == 3

Output Channels

The workflow.out object provides access to the content of all named output Channels (see Nextflow emit):

// channel exists
assert workflow.out.my_channel != null

// channel contains 3 elements
assert workflow.out.my_channel.size() == 3

// first element is "hello"
assert workflow.out.my_channel.get(0) == "hello"


Nextflow script

Create a new file and name it

#!/usr/bin/env nextflow

process sayHello {
        val cheers

        stdout emit: verbiage_ch
        path '*.txt', emit: verbiage_ch2

    echo -n $cheers
    echo -n $cheers > ${cheers}.txt

workflow trial {
    take: things
        trial_out_ch = sayHello.out.verbiage_ch2

workflow {
    Channel.from('hello','nf-test') | trial

nf-test script

Create a new file and name it

nextflow_workflow {

    name "Test Workflow Trial"
    script ""
    workflow "trial"

    test("Should run without failures") {

        when {
            workflow {
                input[0] = Channel.from('hello','nf-test')

        then {

            assert workflow.success

            with(workflow.out.trial_out_ch) {
                assert size() == 2
                assert path(get(0)).readLines().size() == 1
                assert path(get(1)).readLines().size() == 1
                assert path(get(1)).md5 == "4a17df7a54b41a84df492da3f1bab1e3"




Execute test

nf-test init
nf-test test