# Nf-test: Get the relative paths of all files in a pipeline output folder

**URL:** <https://community.seqera.io/t/nf-test-get-the-relative-paths-of-all-files-in-a-pipeline-output-folder/609>\
**Category:** Tips & Tricks\
**Tags:** nf-test\
**Created:** [March 28, 2024, 12:41pm UTC](https://community.seqera.io/t/nf-test-get-the-relative-paths-of-all-files-in-a-pipeline-output-folder/609 "2024-03-28T12:41:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nvnieuwk](https://dub1.discourse-cdn.com/flex013/user_avatar/community.seqera.io/nvnieuwk/32/101_2.png) [@nvnieuwk](https://community.seqera.io/u/nvnieuwk)\
**Post date:** [March 28, 2024, 12:41pm UTC](https://community.seqera.io/t/nf-test-get-the-relative-paths-of-all-files-in-a-pipeline-output-folder/609/1 "2024-03-28T12:41:41Z")

</div>

Sometimes the pipeline outputs are not stable and thus `snapshot(path("${outputDir}").list())` will not be enough since the md5sums created will be different. This snippet shows an alternative way to check if all files in your output folder exist, have the correct name and are in the right subfolders.

A recursive function is used to be able to get the correct paths to all files in the output folder. Paste this function at the end of your `main.nf.test` file:

```groovy
def getRecursiveFileNames(fileOrDir, outputDir) {
    if(file(fileOrDir.toString()).isDirectory()) {
        return fileOrDir.list().collect { getRecursiveFileNames(it, outputDir) }
    }
    return fileOrDir.toString().replace("${outputDir}/", "")
}

```

Apply the function in your assertions in the following way:

```groovy
nextflow_pipeline {

    name "Get all relative paths of the output directory without checking md5sums"
    script "main.nf"

    test("Get all relative paths of the output directory without checking md5sums") {

        when {
            params {
                outdir = outputDir
            }
        }

        then {
            assert snapshot(
                path("${outputDir}")
                    .list()
                    .collect { getRecursiveFileNames(it, outputDir) }
                    .flatten()
            ).match("relative paths")
        }
    }
}

```

An example snapshot is available at

> <https://github.com/nvnieuwk/nf-test-snippets/blob/ed40c37f3d8743a4cb54fbb3d26f64f11f5e96e0/tests/pipeline/relative_paths_outdir/main.nf.test.snap>
