You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/side_quests/nf-test.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ In this part of the training, we're going to show you how to use nf-test to writ
31
31
32
32
---
33
33
34
-
## 0. Warmup
34
+
## Warmup
35
35
36
36
Let's move into the project directory.
37
37
@@ -110,7 +110,7 @@ workflow {
110
110
111
111
We're going to assume an understanding of this workflow, but if you're not sure, you can refer back to [Hello Workflow](../hello_nextflow/03_hello_workflow.md).
112
112
113
-
### 0.1. Run the workflow
113
+
### Run the workflow
114
114
115
115
Let's run the workflow to make sure it's working as expected.
116
116
@@ -150,7 +150,7 @@ Initialize `nf-test`.
150
150
151
151
---
152
152
153
-
## 1.0. Initialize `nf-test`
153
+
## Initialize `nf-test`
154
154
155
155
The `nf-test` package provides an initialization command that sets up a few things in order for us to start developing tests for our project.
156
156
@@ -170,7 +170,7 @@ Project configured. Configuration is stored in nf-test.config
170
170
171
171
It also creates a `tests` directory containing a configuration file stub.
172
172
173
-
## 1.1. Generate an nf-test
173
+
## Generate an nf-test
174
174
175
175
`nf-test` comes with a set of tools for building nf-test files, saving us the majority of the work. These come under the subcommand `generate`. Let's generate a test for the pipeline:
176
176
@@ -255,7 +255,7 @@ Good test names should:
255
255
256
256
As we add more assertions and specific test cases later, we'll use these more descriptive names to make it clear what each test is verifying.
257
257
258
-
## 1.2. Run the test
258
+
## Run the test
259
259
260
260
Let's run the test to see what happens.
261
261
@@ -406,7 +406,7 @@ Test Workflow main.nf
406
406
SUCCESS: Executed 1 tests in 5.239s
407
407
```
408
408
409
-
## 1.3. Add assertions
409
+
## Add assertions
410
410
411
411
A simple check is to ensure our pipeline is running all the processes we expect and not skipping any silently. Remember our pipeline runs 6 processes, one called `sayHello` and one called `convertToUpper` for each of the 3 greetings.
412
412
@@ -473,7 +473,7 @@ SUCCESS: Executed 1 tests in 1.588s
473
473
474
474
Success! The pipeline runs successfully and the test passes. Now we have began to test the details of the pipeline, as well as the overall status.
475
475
476
-
## 1.4. Test the output
476
+
## Test the output
477
477
478
478
Let's add an assertion to our test to check the output file was created. We'll add it as a separate test, with an informative name, to make the results easier to interpret.
479
479
@@ -571,11 +571,11 @@ Learn how to test a Nextflow process.
571
571
572
572
---
573
573
574
-
## 2 Test a Nextflow process
574
+
## Test a Nextflow process
575
575
576
576
We don't have to write tests for every part of the pipeline, but the more tests we have the more comprehensive we can be about the pipeline and the more confident we can be that it's working as expected. In this section we're going to test both processes in the pipeline as individual units.
577
577
578
-
### 2.1. Test the `sayHello` process
578
+
### Test the `sayHello` process
579
579
580
580
Let's start with the `sayHello` process.
581
581
@@ -751,7 +751,7 @@ SUCCESS: Executed 1 tests in 1.611s
751
751
752
752
Success! The test passes because the `sayHello` process ran successfully and the output was created.
753
753
754
-
### 2.2. Check out the snapshot created by the test
754
+
### Check out the snapshot created by the test
755
755
756
756
If we look at the `tests/main.sayhello.nf.test` file, we can see it uses a method `snapshot()` in the assertion block:
757
757
@@ -804,7 +804,7 @@ SUCCESS: Executed 1 tests in 1.685s
804
804
805
805
Success! The test passes because the `sayHello` process ran successfully and the output matched the snapshot.
806
806
807
-
### 2.3 Alternative to Snapshots: Direct Content Assertions
807
+
### Alternative to Snapshots: Direct Content Assertions
808
808
809
809
While snapshots are great for catching any changes in output, sometimes you want to verify specific content without being so strict about the entire file matching. For example:
810
810
@@ -898,7 +898,7 @@ Test Process sayHello
898
898
SUCCESS: Executed 1 tests in 7.208s
899
899
```
900
900
901
-
### 2.4. Test the `convertToUpper` process
901
+
### Test the `convertToUpper` process
902
902
903
903
Let's open the `tests/main.converttoupper.nf.test` file and take a look at the contents:
904
904
@@ -1052,15 +1052,15 @@ You know how to write tests for a Nextflow process and run them.
1052
1052
1053
1053
Learn how to run tests for everything at once!
1054
1054
1055
-
## 3. Run tests for the entire repository
1055
+
## Run tests for the entire repository
1056
1056
1057
1057
Running nf-test on each component is fine, but laborious and error prone. Can't we just test a test on everything at once?
1058
1058
1059
1059
Yes we can!
1060
1060
1061
1061
Let's run nf-test on the entire repo.
1062
1062
1063
-
### 3.1. Run nf-test on the entire repo
1063
+
### Run nf-test on the entire repo
1064
1064
1065
1065
We can run nf-test on the entire repo by running the `nf-test test` command.
1066
1066
@@ -1097,7 +1097,7 @@ SUCCESS: Executed 3 tests in 5.007s
1097
1097
1098
1098
Check that out! We ran 3 tests, 1 for each process and 1 for the whole pipeline with a single command. Imagine how powerful this is on a large codebase!
0 commit comments