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
Wrote process test file '/workspaces/training/side-quests/nf-test/tests/main.sayhello.nf.test
415
+
Wrote process test file '/workspaces/training/side-quests/nf-test/tests/main.converttoupper.nf.test
416
416
417
417
SUCCESS: Generated 2 test files.
418
418
```
419
419
420
-
Note we have created a test for the `converttoupper` process as well. We can ignore that for now and focus on the `sayhello` process in the `main.sayhello.nf.test` file.
420
+
Let's focus for now and focus on the `sayhello` process in the `main.sayhello.nf.test` file.
421
421
422
422
Let's open the file and take a look at the contents.
423
423
@@ -471,7 +471,7 @@ https://www.nf-test.com
471
471
472
472
Test Process sayHello
473
473
474
-
Test [f91a1bcd] 'Should run without failures' FAILED (1.347s)
474
+
Test [1eaad118] 'Should run without failures' FAILED (4.876s)
475
475
476
476
Assertion failed:
477
477
@@ -484,10 +484,15 @@ Test Process sayHello
484
484
485
485
Process `sayHello` declares 1 input channel but 0 were specified
486
486
487
-
-- Check script '/workspace/gitpod/hello-nextflow/hello-nf-test-part1/.nf-test-f91a1bcdafbf4c8bbd32858acdd8afd2.nf' at line: 38 or see '/workspace/gitpod/hello-nextflow/hello-nf-test-part1/.nf-test/tests/f91a1bcdafbf4c8bbd32858acdd8afd2/meta/nextflow.log' file for more details
487
+
-- Check script '/workspaces/training/side-quests/nf-test/.nf-test-1eaad118145a1fd798cb07e7dd75d087.nf' at line: 38 or see '/workspaces/training/side-quests/nf-test/.nf-test/tests/1eaad118145a1fd798cb07e7dd75d087/meta/nextflow.log' file for more details
488
488
Nextflow stderr:
489
489
490
-
FAILURE: Executed 1 tests in 1.35s (1 failed)
490
+
Nextflow 24.10.4 is available - Please consider updating your version to it
491
+
492
+
493
+
494
+
495
+
FAILURE: Executed 1 tests in 4.884s (1 failed)
491
496
```
492
497
493
498
The test fails because the `sayHello` process declares 1 input channel but 0 were specified. Let's fix that by adding an input to the process. Remember from part 1, our `sayHello` process takes a single value input.
@@ -546,7 +551,7 @@ If we look at the `tests/main.sayhello.nf.test` file, we can see it uses a metho
546
551
assert snapshot(process.out).match()
547
552
```
548
553
549
-
This is a snapshot of the output of the `sayHello` process. Let's take a look at the contents of the snapshot file.
554
+
This is telling nf-test to create a snapshot of the output of the `sayHello` process. Let's take a look at the contents of the snapshot file.
550
555
551
556
```console title="Snapshot file contents"
552
557
code tests/main.sayhello.nf.test.snap
@@ -560,7 +565,7 @@ We won't print it here, but you should see a JSON file containing details of the
560
565
]
561
566
```
562
567
563
-
This represents the outputs created by the `sayHello` process, which we are testing explicitly. If we re-run the test, the program will check that the new output matches the output that was originally recorded. This is a quick, simple way of testing process outputs which is why nf-test provides it as a default.
568
+
This represents the outputs created by the `sayHello` process, which we are testing explicitly. If we re-run the test, the program will check that the new output matches the output that was originally recorded. This is a quick, simple way of testing that process outputs don't change, which is why nf-test provides it as a default.
564
569
565
570
!!!warning
566
571
@@ -569,7 +574,7 @@ This represents the outputs created by the `sayHello` process, which we are test
569
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.
570
575
571
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.
572
-
- 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, using the parameter `--update-snapshot`when we run the test command.
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.
573
578
574
579
For now though, we can run the test again and see the test should pass:
575
580
@@ -776,11 +781,3 @@ Check that out! We ran 3 tests, 1 for each process and 1 for the whole pipeline
776
781
### Takeaway
777
782
778
783
You know how to run tests for the entire repo with a single command.
779
-
780
-
### What's next?
781
-
782
-
This is a lot to learn, so celebrate and take a big break!
783
-
784
-
If you already know about Nextflow and wish to learn more about nf-test, skip to nf-test part 2 which uses more real world examples.
785
-
786
-
If you are still at the beginning of your Nextflow journey, you can continue to learn about containers.
0 commit comments