What is the main purpose of performing a code review as part of software testing?
Think about how code review helps catch problems early.
Code review helps testers and developers find bugs and issues in the code before it is deployed, improving software quality.
Which assertion best checks that a function returns the expected output during a code review?
def add(a, b): return a + b result = add(2, 3) # Which assertion is correct to verify the result?
Check what the function is supposed to return for inputs 2 and 3.
The function adds two numbers, so 2 + 3 equals 5. The assertion should check for equality with 5.
During code review, you find this Python function. What error will it cause when called?
def divide(x, y): return x / y result = divide(10, 0)
What happens when you divide a number by zero in Python?
Dividing by zero in Python raises a ZeroDivisionError at runtime.
Which practice is best when reviewing test code in an automated testing framework?
Think about what makes tests easy to understand and reliable.
Good test code should have clear names and cover important cases, making it easier to maintain and trust.
What is the output when running this test code snippet?
def is_even(n): return n % 2 == 0 assert is_even(7) == True
Check if 7 is even and what the assertion expects.
7 is not even, so is_even(7) returns False. The assertion expects True, so it fails with AssertionError.