Created
February 22, 2020 08:06
-
-
Save nohwnd/b5b0155ff300c8e78de2c948157940b7 to your computer and use it in GitHub Desktop.
Pass various parameters to Pester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# output | |
Pester v4.9.0 | |
Executing all tests in 'C:\Users\jajares\Dropbox\pester\parameters.tests.ps1' | |
Executing script C:\Users\jajares\Dropbox\pester\parameters.tests.ps1 | |
Describing a | |
[+] b 31ms | |
[+] c 15ms | |
Describing g | |
[+] Path 14ms | |
Tests completed in 418ms | |
Tests Passed: 3, Failed: 0, Skipped: 0, Pending: 0, Inconclusive: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param($p) | |
function Get-User { | |
@{ | |
Name = "Jakub" | |
Age = 31 | |
} | |
} | |
Describe "a" { | |
BeforeAll { | |
$user = Get-User | |
} | |
It "b" { | |
$user.Name | Should -Be $p.Test1.Name | |
} | |
It "c" { | |
$user.Age | Should -Be $p.Test1.Age | |
} | |
} | |
Describe "g" { | |
It "Path" { | |
$p.Test2.Path | Should -Exist | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Module Pester | Remove-Module | |
Import-Module Pester -MaximumVersion 4.99.99 | |
Invoke-Pester -Script @{ | |
Path = "C:\Users\jajares\Dropbox\pester\parameters.tests.ps1" | |
Parameters = @{ | |
P = @{ | |
Test1 = @{ | |
Name = "Jakub" | |
Age = 31 | |
} | |
Test2 = @{ | |
Path = "C:\temp" | |
} | |
CommonParameter1 = "abc" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment