Test Overview
This test uses the Arrange-Act-Assert pattern to check if the add function correctly adds two numbers. It arranges the inputs, acts by calling the function, and asserts the expected result.
This test uses the Arrange-Act-Assert pattern to check if the add function correctly adds two numbers. It arranges the inputs, acts by calling the function, and asserts the expected result.
import pytest def add(a, b): return a + b def test_add_two_numbers(): # Arrange num1 = 3 num2 = 5 expected_sum = 8 # Act result = add(num1, num2) # Assert assert result == expected_sum, f"Expected {expected_sum} but got {result}"
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | pytest test runner initialized | - | PASS |
| 2 | Arrange inputs: num1=3, num2=5, expected_sum=8 | Variables set in test function | - | PASS |
| 3 | Act by calling add(num1, num2) | Function add called with arguments 3 and 5 | - | PASS |
| 4 | Assert that result equals expected_sum | Result is 8, expected_sum is 8 | assert 8 == 8 | PASS |
| 5 | Test ends | Test passed with no errors | - | PASS |