Bird
0
0

What will be the output when running this Pester test script?

medium📝 Predict Output Q13 of 15
PowerShell - Scripting Best Practices
What will be the output when running this Pester test script?
Describe 'Math Tests' {
  It 'checks addition' {
    (2 + 2) | Should Be 4
  }
  It 'checks subtraction' {
    (5 - 3) | Should Be 1
  }
}
AOne test fails because 5 - 3 is not 1
BBoth tests pass successfully
CSyntax error due to missing parentheses
DAll tests fail because Should Be is used incorrectly
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate each test condition

    The first test checks if 2 + 2 equals 4, which is true. The second test checks if 5 - 3 equals 1, which is false because 5 - 3 equals 2.
  2. Step 2: Determine test results

    Since the second test condition is false, that test fails. The first test passes.
  3. Final Answer:

    One test fails because 5 - 3 is not 1 -> Option A
  4. Quick Check:

    5 - 3 = 2, not 1, so test fails [OK]
Quick Trick: Calculate expressions carefully; check expected values [OK]
Common Mistakes:
  • Assuming 5 - 3 equals 1
  • Ignoring test failure details
  • Thinking Should Be causes syntax errors here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes