PesterTestScriptSources/Module.Tests.ps1
<#
.SYNOPSIS The Pester tests for the test-modulePipline module .DESCRIPTION The Pester tests for the test-modulePipline module Run this via Pester .PARAMETER ModuleName The name of the module #> param( [parameter()] [ValidateNotNull()] $ModuleName ) Write-Verbose "Performing tests for module $ModuleName" # variables $ModulePath = ".\$ModuleName" $ModulePath # Testing the powerShell module Describe "Module validation tests" { It "Modulepath $ModulePath should exist" { (Test-Path $ModulePath) | Should Be $true } It "Import-Module should import $ModulePath without errors" { Import-Module $ModulePath -ErrorAction Stop -ErrorVariable myerror $myerror | Should Be $null } It "Module should contain at least one exported command or DSC resource" { $moduleExports = 0 $moduleExports += (Get-Module $ModuleName).ExportedDscResources.Count $moduleExports += (Get-Module $ModuleName).ExportedFunctions.Count $moduleExports += (Get-Module $ModuleName).ExportedCmdlets.Count $moduleExports | Should BeGreaterThan 0 } } |