community.windows.win_pester 模块 – 在 Windows 主机上运行 Pester 测试
注意
此模块是 community.windows 集合 (版本 2.3.0) 的一部分。
如果您使用的是 ansible
包,则可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install community.windows
。您需要其他要求才能使用此模块,有关详细信息,请参阅 需求。
要在 playbook 中使用它,请指定: community.windows.win_pester
。
概要
在 Windows 主机上运行 Pester 测试。
测试文件必须在远程主机上可用。
需求
执行此模块的主机需要以下需求。
Pester
参数
参数 |
注释 |
---|---|
生成输出测试报告。 |
|
要生成的测试报告的格式。 此参数与 output_file 选项一起使用。 默认值: |
|
Pester 测试文件的路径或可以找到测试的文件夹。 如果路径是文件夹,则模块将所有 ps1 文件都视为 Pester 测试。 |
|
仅运行具有指定 Tags 值的 Describe 块中的测试。 接受多个用逗号分隔的标签。 |
|
允许为测试脚本指定参数。 |
|
必须在远程主机上可用的 pester 模块的最低版本。 |
示例
- name: Get facts
ansible.windows.setup:
- name: Add Pester module
action:
module_name: "{{ 'community.windows.win_psmodule' if ansible_powershell_version >= 5 else 'chocolatey.chocolatey.win_chocolatey' }}"
name: Pester
state: present
- name: Run the pester test provided in the path parameter.
community.windows.win_pester:
path: C:\Pester
- name: Run the pester tests only for the tags specified.
community.windows.win_pester:
path: C:\Pester\TestScript.tests
tags: CI,UnitTests
# Run pesters tests files that are present in the specified folder
# ensure that the pester module version available is greater or equal to the version parameter.
- name: Run the pester test present in a folder and check the Pester module version.
community.windows.win_pester:
path: C:\Pester\test01.test.ps1
version: 4.1.0
- name: Run the pester test present in a folder with given script parameters.
community.windows.win_pester:
path: C:\Pester\test04.test.ps1
test_parameters:
Process: lsass
Service: bits
- name: Run the pester test present in a folder and generate NunitXML test result..
community.windows.win_pester:
path: C:\Pester\test04.test.ps1
output_file: c:\Pester\resullt\testresult.xml
返回值
常见返回值已在 此处 记录,以下是此模块独有的字段
键 |
描述 |
---|---|
Pester 测试的结果。 返回: 成功 示例: |
|
在远程主机上找到的 pester 模块的版本。 返回: 始终 示例: |