Bird
0
0

Which of the following is the correct syntax to write a simple test in Pester that checks if the number 5 is greater than 3?

easy📝 Syntax Q12 of 15
PowerShell - Scripting Best Practices
Which of the following is the correct syntax to write a simple test in Pester that checks if the number 5 is greater than 3?
ATest 'Test' { Check 'checks number' { 5 > 3 ShouldBe True } }
BDescribe 'Test' { It 'checks number' { Should 5 -gt 3 } }
CDescribe 'Test' { It 'checks number' { 5 -gt 3 | Should Be $true } }
DIt 'checks number' { 5 -gt 3 ShouldBe $true }
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct Pester syntax

    The correct syntax uses Describe to group, It for the test, and pipes the condition to Should Be $true.
  2. Step 2: Check each option

    Describe 'Test' { It 'checks number' { 5 -gt 3 | Should Be $true } } correctly uses Describe, It, and pipes the boolean expression to Should Be $true. Others have syntax errors or wrong keywords.
  3. Final Answer:

    Describe 'Test' { It 'checks number' { 5 -gt 3 | Should Be $true } } -> Option C
  4. Quick Check:

    Correct syntax uses Describe, It, and Should Be [OK]
Quick Trick: Use Describe and It blocks; pipe condition to Should Be [OK]
Common Mistakes:
  • Using wrong keywords like Test or Check
  • Missing pipe before Should
  • Incorrect comparison operators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes