Skip to content

Instantly share code, notes, and snippets.

@k2works
Last active February 24, 2021 04:00
Show Gist options
  • Save k2works/7b20abf36d4c226d202b877129457f6b to your computer and use it in GitHub Desktop.
Save k2works/7b20abf36d4c226d202b877129457f6b to your computer and use it in GitHub Desktop.
PowerShell TDD Startter
function add ([int]$a, [int]$b) {
$sum = $a + $b
$sum
}
Describe "TestAdd" {
It "合計を返す" {
$result = add 2 2
$result | Should Be 4
}
}
#https://qiita.com/opengl-8080/items/bb0f5e4f1c7ce045cc57
function HelloWorld($name = 'Pester') {
return "Hello from $name"
}
Describe "HelloWorld" {
It "何か便利なものだ" {
$true | Should Be $true
}
It "何も指定しない場合は規定の名前で簡潔なフレーズを返す" {
HelloWorld | Should Be "Hello from Pester"
}
It "指定した名前で簡潔なフレーズを返す" {
HelloWorld "Venus" | Should Be "Hello from Venus"
}
It "いずれかの名前で終わるフレーズを返す" {
HelloWorld "Mars" | Should Match ".*Mars"
}
}
#https://www.red-gate.com/simple-talk/sysadmin/powershell/practical-powershell-unit-testing-getting-started/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment