Skip to content

PSModule/Test-PSModule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Test-PSModule

Test PowerShell modules with Pester and PSScriptAnalyzer.

This GitHub Action is a part of the PSModule framework. It is recommended to use the Process-PSModule workflow to automate the whole process of managing the PowerShell module.

Specifications and practices

Test-PSModule follows:

How it works

The action runs the following the Pester test framework:

The action fails if any of the tests fail or it fails to run the tests.

How to use it

To use the action, create a new file in the .github/workflows directory of the module repository and add the following content.

Workflow suggestion - before module is built
name: Test-PSModule

on: [push]

jobs:
  Test-PSModule:
    name: Test-PSModule
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v4

      - name: Initialize environment
        uses: PSModule/Initialize-PSModule@main

      - name: Test-PSModule
        uses: PSModule/Test-PSModule@main
        with:
          Name: PSModule # Needed if the repo is not named the same as the module
          Path: src
          RunModuleTests: false
Workflow suggestion - after module is built
name: Test-PSModule

on: [push]

jobs:
  Test-PSModule:
    name: Test-PSModule
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v4

      - name: Initialize environment
        uses: PSModule/Initialize-PSModule@main

      - name: Test-PSModule
        uses: PSModule/Test-PSModule@main
        with:
          Name: PSModule
          Path: outputs/modules

Usage

Inputs

Name Description Required Default
Name The name of the module to test. The name of the repository is used if not specified. false
Path The path to the module to test. true
RunModuleTests Run the module tests. false true
Shell The shell to use for running the tests. false pwsh

PSModule tests

The PSModule framework tests verifies the following coding practices that the framework enforces:

  • Script filename and function/filter name should match.

Tools

About

Test PowerShell modules with Pester and PSScriptAnalyzer.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors 2

  •  
  •