Add output options for win_pester (#63583)
* add output options for win_pester * fix typo * correct variable name
This commit is contained in:
parent
c0331053db
commit
4bf79de8a6
4 changed files with 41 additions and 0 deletions
|
@ -15,6 +15,8 @@ $diff_mode = Get-AnsibleParam -obj $params -name "_ansible_diff" -type "bool" -d
|
|||
|
||||
$path = Get-AnsibleParam -obj $params -name "path" -type "str" -failifempty $true
|
||||
$tags = Get-AnsibleParam -obj $params -name "tags" -type "list"
|
||||
$output_file = Get-AnsibleParam -obj $params -name "output_file" -type "str"
|
||||
$output_format = Get-AnsibleParam -obj $params -name "output_format" -type "str" -default "NunitXML"
|
||||
$test_parameters = Get-AnsibleParam -obj $params -name "test_parameters" -type "dict"
|
||||
$minimum_version = Get-AnsibleParam -obj $params -name "minimum_version" -type "str" -failifempty $false
|
||||
|
||||
|
@ -77,6 +79,11 @@ If ($result.pester_version -ge "4.0.0") {
|
|||
if($tags.count){
|
||||
$Parameters.Tag = $tags
|
||||
}
|
||||
|
||||
if($output_file){
|
||||
$Parameters.OutputFile = $output_file
|
||||
$Parameters.OutputFormat = $output_format
|
||||
}
|
||||
# Run Pester tests
|
||||
If (Test-Path -LiteralPath $path -PathType Leaf) {
|
||||
$test_parameters_check_mode_msg = ''
|
||||
|
|
|
@ -32,6 +32,18 @@ options:
|
|||
- Accepts multiple comma separated tags.
|
||||
type: list
|
||||
version_added: '2.9'
|
||||
output_file:
|
||||
description:
|
||||
- Generates an output test report.
|
||||
type: str
|
||||
version_added: '2.10'
|
||||
output_format:
|
||||
description:
|
||||
- Format of the test report to be generated.
|
||||
- This parameter is to be used with output_file option.
|
||||
type: str
|
||||
default: NunitXML
|
||||
version_added: '2.10'
|
||||
test_parameters:
|
||||
description:
|
||||
- Allows to specify parameters to the test script.
|
||||
|
@ -42,6 +54,7 @@ options:
|
|||
- Minimum version of the pester module that has to be available on the remote host.
|
||||
author:
|
||||
- Erwan Quelin (@equelin)
|
||||
- Prasoon Karunan V (@prasoonkarunan)
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
|
@ -76,6 +89,11 @@ EXAMPLES = r'''
|
|||
test_parameters:
|
||||
Process: lsass
|
||||
Service: bits
|
||||
|
||||
- name: Run the pester test present in a folder and generate NunitXML test result..
|
||||
win_pester:
|
||||
path: C:\Pester\test04.test.ps1
|
||||
output_file: c:\Pester\resullt\testresult.xml
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
---
|
||||
test_win_pester_path: C:\ansible\win_pester
|
||||
test_report_file: c:\ansible\win_pester\test_report.xml
|
||||
|
|
|
@ -117,3 +117,18 @@
|
|||
- test_with_parameter.changed
|
||||
- test_with_parameter.output.PassedCount == 2
|
||||
- test_with_parameter.output.TotalCount == 2
|
||||
|
||||
- name: Run Pester test(s) specifying a test file by generating test result xml
|
||||
win_pester:
|
||||
path: '{{test_win_pester_path}}\test03.test.ps1'
|
||||
output_file: '{{test_report_file}}'
|
||||
|
||||
- name: Checks if the output result file exists
|
||||
win_stat:
|
||||
path: '{{test_report_file}}'
|
||||
register: test_output_file
|
||||
|
||||
- name: Checks if the output result file exists
|
||||
assert:
|
||||
that:
|
||||
- test_output_file.stat.exists
|
||||
|
|
Loading…
Reference in a new issue