---
# System prepended metadata

title: pipeline level nf-test assertion reference

---

# pipeline level nf-test assertion reference

## Checking the presence of strings in a file

### Checking the presence of an exact line in a file

Search for a string (or regex) in an output file and check for an exactly matching line.

```
assertAll {
    { assert snapshot(
        
    )}
}
```

## Checking number of rows of a file

### Checking the exact number of rows

The below tests should all go _inside_ the `assert snapshot()` block so that the output becomes part of the snapshot, testing matching output.

```
assertAll {
    { assert snapshot(
        // Test the number of lines in a non-gzipped tsv file
        file(process.out.tsv).readLines.size(),
        // and in a gzipped tsv
        file("${params.outdir}/process/file.tsv.gz").linesGzip.size()
    ).match() }
}
```

### Checking a minimum number of rows

For files that don't have a stable number of rows, but you want to make sure they're of a minimum size

```
assertAll {
    // Check that a gzipped file contains a minimum of 3000 lines
    { assert path("${params.outdir}/process/another_file.tsv.gz").linesGzip.size > 3000 }
}