-
Couldn't load subscription status.
- Fork 253
fix: update docs on nf-test #3306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1786187
89e12fb
3fd9793
885d5aa
8a238d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,8 @@ when { | |
| this can be added at the top of `main.nf.test` to have all tests run in stub mode or this can also be added to a single test | ||
| ::: | ||
|
|
||
| - The test names should be descriptive and easily distinguishable. One possibility is `data origin - data format - other flags`, for example `human - [bam,bai] - create_bed`. The `other flags` should serve as a way to distinguish between different tests which have similar inputs. | ||
|
|
||
| :::tip | ||
| See the [assertions documentation](/docs/contributing/nf-test/assertions) for examples on how to handle different types of test data and scenarios. | ||
| ::: | ||
|
|
@@ -75,6 +77,12 @@ See the [assertions documentation](/docs/contributing/nf-test/assertions) for ex | |
|
|
||
| - For modules that involve running more than one process to generate required test-data (aka chained modules), nf-test provides a [setup](https://code.askimed.com/nf-test/docs/testcases/setup/) method. | ||
|
|
||
| - The setup block can be moved out of the test block and be reused over multiple tests. If different inputs for the same setup process are needed they can be used with aliases: | ||
|
|
||
| ```groovy | ||
| run("GATK_UNIFIEDGENOTYPER", alias: "GATK_UNIFIEDGENOTYPERSNPS") | ||
| ``` | ||
|
|
||
| - For example, the module `abricate/summary` requires the process `abricate/run` to be run prior and takes its output as input. The `setup` method is to be declared before the primary `when` block in the test file as shown below: | ||
|
|
||
| ```groovy title="main.nf.test" | ||
|
|
@@ -128,24 +136,51 @@ nextflow_process { | |
| tag "abricate" | ||
| tag "abricate/summary" | ||
|
|
||
| setup { | ||
| run("ABRICATE_RUN") { | ||
| script "../../run/main.nf" | ||
| process { | ||
| """ | ||
| input[0] = Channel.fromList([ | ||
| tuple([ id:'test1', single_end:false ], // meta map | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tend to remove everything even the Channel statetement |
||
| file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/genome/genome.fna.gz', checkIfExists: true)), | ||
| tuple( | ||
| [ id:'test2', single_end:false ], | ||
| file(params.modules_testdata_base_path + 'genomics/prokaryotes/haemophilus_influenzae/genome/genome.fna.gz', checkIfExists: true) | ||
| ) | ||
| ]) | ||
| """ | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test("bacteroides_fragilis - genome_fna_gz") { | ||
|
|
||
| setup { | ||
| run("ABRICATE_RUN") { | ||
| script "../../run/main.nf" | ||
| process { | ||
| when { | ||
| process { | ||
| """ | ||
| input[0] = Channel.fromList([ | ||
| tuple([ id:'test1', single_end:false ], // meta map | ||
| file(params.modules_testdata_base_path + 'genomics/prokaryotes/bacteroides_fragilis/genome/genome.fna.gz', checkIfExists: true)), | ||
| tuple([ id:'test2', single_end:false ], | ||
| file(params.modules_testdata_base_path + 'genomics/prokaryotes/haemophilus_influenzae/genome/genome.fna.gz', checkIfExists: true)) | ||
| ]) | ||
| input[0] = ABRICATE_RUN.out.report | ||
| .collect{ meta, report -> report } | ||
| .map{ report -> [ [ id: 'test_summary' ], report ] } | ||
| """ | ||
| } | ||
| } | ||
| } | ||
|
|
||
| then { | ||
| assertAll( | ||
| { assert process.success }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can do as @SPPearce suggested and put the assert process.success before the assertAll? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, this would be nice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not so sure about that either |
||
| { assert snapshot( | ||
| process.out, | ||
| path(process.out.versions[0]).yaml | ||
| ).match() } | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| test("bacteroides_fragilis - genome_fna_gz - stub") { | ||
famosab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| options "-stub" | ||
LouisLeNezet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| when { | ||
| process { | ||
| """ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.