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-13Lines changed: 15 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,10 +13,10 @@ As you develop your pipeline, it will quickly become so complex that manually te
13
13
14
14
Testing allows you to systematically check that every part of your pipeline is working as expected. The benefits to a developer are huge:
15
15
16
-
-**Confidence**: Because the tests cover the entire pipeline, you can be be confident changing something doesn't affect anything else
17
-
-**Trust**: When multiple developers work on the pipeline, they know the other developers haven't broken the pipeline and every component.
18
-
-**Transparency**: The tests show where a pipeline is failing and make it easier to track down the problem. They also function as a form of documentation, showing how to run a process or workflow.
19
-
-**Speed**: Because the tests are automated, they can be run very quickly and repeatedly. You can iterate quickly with less fear of introducing new bugs.
16
+
-**Confidence**: Because the tests cover the entire pipeline, you can be be confident changing something doesn't affect anything else
17
+
-**Trust**: When multiple developers work on the pipeline, they know the other developers haven't broken the pipeline and every component.
18
+
-**Transparency**: The tests show where a pipeline is failing and make it easier to track down the problem. They also function as a form of documentation, showing how to run a process or workflow.
19
+
-**Speed**: Because the tests are automated, they can be run very quickly and repeatedly. You can iterate quickly with less fear of introducing new bugs.
20
20
21
21
There are lots of different types of tests we can write:
22
22
@@ -157,13 +157,13 @@ We'll take a second to understand the structure of the test file.
157
157
158
158
The `nextflow_pipeline` block is the entry point for all pipeline level tests. It contains the following:
159
159
160
-
-`name`: The name of the test.
161
-
-`script`: The path to the pipeline script.
160
+
-`name`: The name of the test.
161
+
-`script`: The path to the pipeline script.
162
162
163
163
The `test` block is the actual test. It contains the following:
164
164
165
-
-`when`: The conditions under which the test should be run. This includes the parameters that will be used to run the pipeline.
166
-
-`then`: The assertions that should be made. This includes the expected outcomes of the pipeline.
165
+
-`when`: The conditions under which the test should be run. This includes the parameters that will be used to run the pipeline.
166
+
-`then`: The assertions that should be made. This includes the expected outcomes of the pipeline.
167
167
168
168
In plain English, the logic of the test reads as follows:
169
169
"**When** these _parameters_ are provided to this _pipeline_, **then** we expect to see these results."
@@ -573,8 +573,8 @@ This represents the outputs created by the `sayHello` process, which we are test
573
573
574
574
If, in the course of future development, something in the code changes that causes the output to be different, the test will fail and we will have to determine whether the change is expected or not.
575
575
576
-
-If it turns out that something in the code broke, we will have to fix it, with the expectation that the fixed code will pass the test.
577
-
-If it is an expected change (e.g., the tool has been improved and the results are better) then we will need to update the snapshot to accept the new output as the reference to match. nf-test has a parameter `--update-snapshot` for this purpose.
576
+
- If it turns out that something in the code broke, we will have to fix it, with the expectation that the fixed code will pass the test.
577
+
- If it is an expected change (e.g., the tool has been improved and the results are better) then we will need to update the snapshot to accept the new output as the reference to match. nf-test has a parameter `--update-snapshot` for this purpose.
578
578
579
579
For now though, we can run the test again and see the test should pass:
580
580
@@ -636,9 +636,9 @@ This is a similar test to the `sayHello` process, but it's testing the `convertT
636
636
637
637
We now need to supply a single input file to the convertToUpper process, which includes some text that we want to convert to uppercase. There are lots of ways we could do this:
638
638
639
-
-We could create a dedicated file to test
640
-
-We could re-use the existing data/greetings.csv file
641
-
-We could create it on the fly within the test
639
+
- We could create a dedicated file to test
640
+
- We could re-use the existing data/greetings.csv file
641
+
- We could create it on the fly within the test
642
642
643
643
For now, let's re-use the existing data/greetings.csv file using the example we used with the pipeline level test.
644
644
@@ -775,6 +775,7 @@ In this side quest, we've learned:
775
775
5. How to run all tests in a repository with a single command
776
776
777
777
Testing is a critical part of pipeline development that helps ensure:
778
+
778
779
- Your code works as expected
779
780
- Changes don't break existing functionality
780
781
- Other developers can contribute with confidence
@@ -783,6 +784,7 @@ Testing is a critical part of pipeline development that helps ensure:
783
784
### What's next?
784
785
785
786
Check out the [nf-test documentation](https://www.nf-test.com/) for more advanced testing features and best practices. You might want to:
787
+
786
788
- Add more comprehensive assertions to your tests
787
789
- Write tests for edge cases and error conditions
788
790
- Set up continuous integration to run tests automatically
0 commit comments