0
0
PowerShellscripting~5 mins

Pester testing framework basics in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is Pester in PowerShell?
Pester is a testing framework for PowerShell scripts. It helps you write tests to check if your scripts work as expected.
Click to reveal answer
beginner
What is a Describe block in Pester?
A Describe block groups related tests together. Think of it like a chapter title for your tests.
Click to reveal answer
beginner
What does the It block do in Pester?
An It block contains a single test. It describes what the test should check, like a small task or question.
Click to reveal answer
beginner
How do you check if a value equals another in Pester?
Use the Should keyword with the -Be operator. For example: $result | Should -Be 5 checks if $result equals 5.
Click to reveal answer
beginner
How do you run Pester tests in PowerShell?
Run the command Invoke-Pester in the folder with your test files. It runs all tests and shows results.
Click to reveal answer
What keyword starts a group of tests in Pester?
AShould
BIt
CDescribe
DTest
Which block contains a single test in Pester?
AIt
BTest-Case
CShould
DDescribe
How do you assert that a value equals 10 in Pester?
AAssert-Equal $value 10
B$value | Should -Equal 10
C$value -eq 10
D$value | Should -Be 10
Which command runs all Pester tests in the current folder?
ARun-Pester
BInvoke-Pester
CStart-Test
DTest-Invoke
What is the main purpose of Pester?
ATo test PowerShell scripts
BTo write PowerShell scripts
CTo deploy PowerShell scripts
DTo debug PowerShell scripts
Explain the roles of Describe and It blocks in Pester testing.
Think of Describe as a chapter and It as a paragraph.
You got /3 concepts.
    How do you write a simple test in Pester to check if a function returns the number 5?
    Start with Describe, then It, then assertion.
    You got /4 concepts.