community.windows.win_pester (2.2.0) — module

Run Pester tests on Windows hosts

Authors: Erwan Quelin (@equelin), Prasoon Karunan V (@prasoonkarunan)

Install collection

Install with ansible-galaxy collection install community.windows:==2.2.0


Add to requirements.yml

  collections:
    - name: community.windows
      version: 2.2.0

Description

Run Pester tests on Windows hosts.

Test files have to be available on the remote host.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get facts
  ansible.windows.setup:
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run the pester test provided in the path parameter.
  community.windows.win_pester:
    path: C:\Pester
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run the pester tests only for the tags specified.
  community.windows.win_pester:
    path: C:\Pester\TestScript.tests
    tags: CI,UnitTests
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Inputs

    
path:
    description:
    - Path to a pester test file or a folder where tests can be found.
    - If the path is a folder, the module will consider all ps1 files as Pester tests.
    required: true
    type: str

tags:
    description:
    - Runs only tests in Describe blocks with specified Tags values.
    - Accepts multiple comma separated tags.
    elements: str
    type: list

version:
    aliases:
    - minimum_version
    description:
    - Minimum version of the pester module that has to be available on the remote host.
    type: str

output_file:
    description:
    - Generates an output test report.
    type: str

output_format:
    default: NunitXML
    description:
    - Format of the test report to be generated.
    - This parameter is to be used with output_file option.
    type: str

test_parameters:
    description:
    - Allows to specify parameters to the test script.
    type: dict

Outputs

output:
  description: Results of the Pester tests.
  returned: success
  sample: false
  type: list
pester_version:
  description: Version of the pester module found on the remote host.
  returned: always
  sample: 4.3.1
  type: str