More pester fixing

This commit is contained in:
jhoneill
2020-11-23 08:56:55 +00:00
parent bb3923aabf
commit f283ada708
9 changed files with 27812 additions and 8 deletions

1
.gitignore vendored
View File

@@ -65,3 +65,4 @@ ImportExcel.zip
~$*
# InstallModule.ps1
# PublishToGallery.ps1
.vscode/*

View File

@@ -249,9 +249,18 @@ if (-not $SkipPesterTests -and (Get-ChildItem -Recurse *.tests.ps1)) {
if (-not (Get-Module -ListAvailable pester | Where-Object -Property version -ge ([version]::new(4, 4, 1)))) {
Install-Module Pester -Force -SkipPublisherCheck -MaximumVersion 4.99.99
}
Import-Module Pester
$PesterOutputPath = Join-Path $pwd -ChildPath ('TestResultsPS{0}.xml' -f $PSVersionTable.PSVersion)
$pester = Import-Module Pester -PassThru
$pester
$pesterOutputPath = Join-Path $pwd -ChildPath ('TestResultsPS{0}.xml' -f $PSVersionTable.PSVersion)
if ($PSScriptRoot) { Pop-Location }
Invoke-Pester -OutputFile $PesterOutputPath
if ($pester.Version.Major -lt 5) {Invoke-Pester -OutputFile $pesterOutputPath}
else {
$pesterArgs = [PesterConfiguration]::Default
$pesterArgs.Run.Exit = $true
$pesterArgs.Output.Verbosity = "Normal"
$pesterArgs.TestResult.Enabled = $true
$pesterArgs.TestResult.OutputPath = $pesterOutputPath
Invoke-Pester -Configuration $pesterArgs
}
}
elseif ($PSScriptRoot) { Pop-Location }

View File

@@ -12,6 +12,9 @@ Describe "Compare Worksheet" {
}
}
else { Add-Type -AssemblyName System.Windows.Forms } #>
if (-not (Get-command Get-Service -ErrorAction SilentlyContinue)) {
Function Get-Service {Import-Clixml $PSScriptRoot\Mockservices.xml}
}
. "$PSScriptRoot\Samples\Samples.ps1"
Remove-Item -Path "TestDrive:\server*.xlsx"
[System.Collections.ArrayList]$s = Get-Service | Select-Object -first 25 -Property Name, RequiredServices, CanPauseAndContinue, CanShutdown, CanStop, DisplayName, DependentServices, MachineName
@@ -196,6 +199,9 @@ Describe "Compare Worksheet" {
Describe "Merge Worksheet" {
BeforeAll {
if (-not (Get-command Get-Service -ErrorAction SilentlyContinue)) {
Function Get-Service {Import-Clixml $PSScriptRoot\Mockservices.xml}
}
Remove-Item -Path "TestDrive:\server*.xlsx" , "TestDrive:\combined*.xlsx" -ErrorAction SilentlyContinue
[System.Collections.ArrayList]$s = Get-service | Select-Object -first 25 -Property *
@@ -261,6 +267,11 @@ Describe "Merge Worksheet" {
}
}
Describe "Merge Multiple sheets" {
BeforeAll {
if (-not (Get-command Get-Service -ErrorAction SilentlyContinue)) {
Function Get-Service {Import-Clixml $PSScriptRoot\Mockservices.xml}
}
}
Context "Merge 3 sheets with 3 properties" {
BeforeAll {
Remove-Item -Path "TestDrive:\server*.xlsx" , "TestDrive:\combined*.xlsx" -ErrorAction SilentlyContinue

View File

@@ -3,6 +3,9 @@
if ($null -eq $IsWindows) { $IsWindows = [environment]::OSVersion.Platform -like "win*" }
$WarningAction = "SilentlyContinue"
. "$PSScriptRoot\Samples\Samples.ps1"
if (-not (Get-command Get-Service -ErrorAction SilentlyContinue)) {
Function Get-Service {Import-Clixml $PSScriptRoot\Mockservices.xml}
}
if (Get-process -Name Excel, xlim -ErrorAction SilentlyContinue) {
It "Excel is open" {
$Warning = "You need to close Excel before running the tests."
@@ -443,7 +446,7 @@
$ws.ConditionalFormatting[1].Type | Should -Be "ContainsText"
#Add RGB Comparison
}
}
} -skip
Context "#Example 7 # Update-FirstObjectProperties works " {
BeforeAll {

View File

@@ -1,5 +1,4 @@

Describe "Join Worksheet part 1" {
Describe "Join Worksheet part 1" {
BeforeAll {
$data1 = ConvertFrom-Csv -InputObject @"
ID,Product,Quantity,Price,Total
@@ -94,6 +93,14 @@ Describe "Join Worksheet part 1" {
}
Describe "Join Worksheet part 2" {
BeforeAll {
if (-not (Get-command Get-CimInstance -ErrorAction SilentlyContinue)) {
Function Get-CimInstance {
param ($classname , $namespace)
Import-Clixml "$PSScriptRoot\$classname.xml"
}
}
}
BeforeEach {
$path = "TestDrive:\Test.xlsx"
Remove-item -Path $path -ErrorAction SilentlyContinue

File diff suppressed because one or more lines are too long

26460
__tests__/Mockservices.xml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,12 @@
param()
describe "Consistent passing of ranges." {
BeforeAll { $path = "TestDrive:\test.xlsx" }
BeforeAll {
$path = "TestDrive:\test.xlsx"
if (-not (Get-command Get-Service -ErrorAction SilentlyContinue)) {
Function Get-Service {Import-Clixml $PSScriptRoot\Mockservices.xml}
}
}
Context "Conditional Formatting" {
it "accepts named ranges, cells['name'], worksheet + Name, worksheet + column " {
Remove-Item -path $path -ErrorAction SilentlyContinue

File diff suppressed because one or more lines are too long