Private/Tests/!StartAllTests.ps1

# ? TITEL Startet alle AKPT-Tests
# ? DESCRIPTION Zentraler Starter für alle Pester UTest (Cmdlets und Module).
# ? TAGS UTest Pester Module
# ? VERSION 2020.01.14

using Module  CimCmdlets
using Module  Microsoft.PowerShell.Management
using Module  Microsoft.PowerShell.Security
using Module  Microsoft.PowerShell.Utility
using Module  Microsoft.WSMan.Management
using Module  Pester
using Module  PSScriptAnalyzer

using namespace System
using namespace System.Management.Automation

$ErrorActionPreference = [ActionPreference]::Stop

Set-StrictMode -Version Latest

$testScriptPath = Split-Path -Path $MyInvocation.MyCommand.Path

# ! UTest inkl. Code-Abdeckung ausführen
$UTestsFullName = Get-ChildItem -Path "$testScriptPath\*-*.Tests.ps1" -File | Select-Object -ExpandProperty FullName
$cmdletsFullName = ($UTestsFullName -replace ".Test.", [String]::Empty) -replace "Private", "Public"
$UTestsFullName += "$testScriptPath\AKPT.Tests.ps1" # zzgl. Module-Test
$cmdletTestResult = Invoke-Pester -Script $UTestsFullName -CodeCoverage $cmdletsFullName -Show All -PassThru 
$cmdletTestResult.TestResult | Where-Object Passed -EQ $False