Skip to content

Commit 01abaf0

Browse files
Improve code block comparison
I added line numbers and line highlights to make it easier to realise which lines changed from "Before" to "After". When testing the training, sometimes it wasn't so straightforward to see what changed and line numbers are very useful when teaching.
1 parent bfb75f0 commit 01abaf0

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

docs/side_quests/nf-test.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ You may be wondering how we're going to point to the root of the pipeline in the
326326

327327
_Before:_
328328

329-
```groovy title="tests/main.nf.test"
329+
```groovy title="tests/main.nf.test" linenums="1" hl_lines="3 4"
330330
when {
331331
params {
332332
// define parameters here. Example:
@@ -337,7 +337,7 @@ when {
337337

338338
_After:_
339339

340-
```groovy title="tests/main.nf.test"
340+
```groovy title="tests/main.nf.test" linenums="1" hl_lines="3"
341341
when {
342342
params {
343343
input_file = "${projectDir}/greetings.csv"
@@ -409,7 +409,7 @@ Let's add an assertion to our test to check the pipeline runs the expected numbe
409409

410410
**Before:**
411411

412-
```groovy title="tests/main.nf.test"
412+
```groovy title="tests/main.nf.test" linenums="1" hl_lines="1 11"
413413
test("Should run without failures") {
414414
415415
when {
@@ -427,7 +427,7 @@ Let's add an assertion to our test to check the pipeline runs the expected numbe
427427

428428
**After:**
429429

430-
```groovy title="tests/main.nf.test"
430+
```groovy title="tests/main.nf.test" linenums="1" hl_lines="1 11"
431431
test("Should run successfully with correct number of processes") {
432432
433433
when {
@@ -474,7 +474,7 @@ Let's add an assertion to our test to check the output file was created. We'll a
474474

475475
**Before:**
476476

477-
```groovy title="tests/main.nf.test"
477+
```groovy title="tests/main.nf.test" linenums="1" hl_lines="14"
478478
test("Should run successfully with correct number of processes") {
479479
480480
when {
@@ -493,7 +493,7 @@ Let's add an assertion to our test to check the output file was created. We'll a
493493

494494
**After:**
495495

496-
```groovy title="tests/main.nf.test"
496+
```groovy title="tests/main.nf.test" linenums="1" hl_lines="14-33"
497497
test("Should run successfully with correct number of processes") {
498498
499499
when {
@@ -667,7 +667,7 @@ The test fails because the `sayHello` process declares 1 input channel but 0 wer
667667

668668
**Before:**
669669

670-
```groovy title="tests/main.sayhello.nf.test"
670+
```groovy title="tests/main.sayhello.nf.test" linenums="1" hl_lines="1 10 11"
671671
test("Should run without failures") {
672672
673673
when {
@@ -693,7 +693,7 @@ The test fails because the `sayHello` process declares 1 input channel but 0 wer
693693

694694
**After:**
695695

696-
```groovy title="tests/main.sayhello.nf.test"
696+
```groovy title="tests/main.sayhello.nf.test" linenums="1" hl_lines="1 10"
697697
test("Should run without failures and produce correct output") {
698698
699699
when {
@@ -806,10 +806,8 @@ Here's how we could modify our test to check specific content:
806806

807807
**Before:**
808808

809-
```groovy title="tests/main.sayhello.nf.test"
810-
process {
811-
"""
812-
test("Should run without failures and produce correct output") {
809+
```groovy title="tests/main.sayhello.nf.test" linenums="1" hl_lines="1 5 6 17"
810+
test("Should run without failures and produce correct output") {
813811
814812
when {
815813
params {
@@ -829,15 +827,13 @@ process {
829827
}
830828
831829
}
832-
833-
"""
834-
}
835830
```
836831

837832
**After:**
838833

839-
```groovy title="tests/main.sayhello.nf.test"
834+
```groovy title="tests/main.sayhello.nf.test" linenums="1" hl_lines="1 5 16 17"
840835
test("Should run without failures and contain expected greeting") {
836+
841837
when {
842838
params {
843839
// define parameters here
@@ -854,6 +850,7 @@ process {
854850
assert path(process.out[0][0]).readLines().contains('hello')
855851
assert !path(process.out[0][0]).readLines().contains('HELLO')
856852
}
853+
857854
}
858855
```
859856

@@ -936,7 +933,7 @@ For now, let's re-use the existing data/greetings.csv file using the example we
936933

937934
**Before:**
938935

939-
```groovy title="tests/main.converttoupper.nf.test"
936+
```groovy title="tests/main.converttoupper.nf.test" linenums="1" hl_lines="1 10 11"
940937
test("Should run without failures") {
941938
942939
when {
@@ -962,7 +959,7 @@ For now, let's re-use the existing data/greetings.csv file using the example we
962959

963960
**After:**
964961

965-
```groovy title="tests/main.converttoupper.nf.test"
962+
```groovy title="tests/main.converttoupper.nf.test" linenums="1" hl_lines="1 10"
966963
test("Should run without failures and produce correct output") {
967964
968965
when {

0 commit comments

Comments
 (0)