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
-
## Warmup
34
+
## 0. 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
-
### Run the workflow
113
+
### 0.1. 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
-
## Initialize `nf-test`
153
+
## 1.0. 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
-
## Generate an nf-test
173
+
## 1.1. 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
-
## Run the test
258
+
## 1.2. Run the test
259
259
260
260
Let's run the test to see what happens.
261
261
@@ -401,7 +401,7 @@ Test Workflow main.nf
401
401
SUCCESS: Executed 1 tests in 5.239s
402
402
```
403
403
404
-
## Add assertions
404
+
## 1.3. Add assertions
405
405
406
406
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.
407
407
@@ -468,7 +468,7 @@ SUCCESS: Executed 1 tests in 1.588s
468
468
469
469
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.
470
470
471
-
## Test the output
471
+
## 1.4. Test the output
472
472
473
473
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.
474
474
@@ -566,11 +566,11 @@ Learn how to test a Nextflow process.
566
566
567
567
---
568
568
569
-
## Test a Nextflow process
569
+
## 2 Test a Nextflow process
570
570
571
571
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.
572
572
573
-
### Test the `sayHello` process
573
+
### 2.1. Test the `sayHello` process
574
574
575
575
Let's start with the `sayHello` process.
576
576
@@ -741,7 +741,7 @@ SUCCESS: Executed 1 tests in 1.611s
741
741
742
742
Success! The test passes because the `sayHello` process ran successfully and the output was created.
743
743
744
-
### Check out the snapshot created by the test
744
+
### 2.2. Check out the snapshot created by the test
745
745
746
746
If we look at the `tests/main.sayhello.nf.test` file, we can see it uses a method `snapshot()` in the assertion block:
747
747
@@ -794,7 +794,7 @@ SUCCESS: Executed 1 tests in 1.685s
794
794
795
795
Success! The test passes because the `sayHello` process ran successfully and the output matched the snapshot.
796
796
797
-
### Alternative to Snapshots: Direct Content Assertions
797
+
### 2.3 Alternative to Snapshots: Direct Content Assertions
798
798
799
799
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:
800
800
@@ -888,7 +888,7 @@ Test Process sayHello
888
888
SUCCESS: Executed 1 tests in 7.208s
889
889
```
890
890
891
-
### Test the `convertToUpper` process
891
+
### 2.4. Test the `convertToUpper` process
892
892
893
893
Let's open the `tests/main.converttoupper.nf.test` file and take a look at the contents:
894
894
@@ -1042,15 +1042,15 @@ You know how to write tests for a Nextflow process and run them.
1042
1042
1043
1043
Learn how to run tests for everything at once!
1044
1044
1045
-
## Run tests for the entire repository
1045
+
## 3. Run tests for the entire repository
1046
1046
1047
1047
Running nf-test on each component is fine, but laborious and error prone. Can't we just test a test on everything at once?
1048
1048
1049
1049
Yes we can!
1050
1050
1051
1051
Let's run nf-test on the entire repo.
1052
1052
1053
-
### Run nf-test on the entire repo
1053
+
### 3.1. Run nf-test on the entire repo
1054
1054
1055
1055
We can run nf-test on the entire repo by running the `nf-test test` command.
1056
1056
@@ -1087,7 +1087,7 @@ SUCCESS: Executed 3 tests in 5.007s
1087
1087
1088
1088
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