0
0
Testing Fundamentalstesting~10 mins

What software testing is in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test checks if the software testing process correctly identifies a simple bug in a calculator app by verifying the addition function works as expected.

Test Code - unittest
Testing Fundamentals
import unittest

class Calculator:
    def add(self, a, b):
        return a + b

class TestCalculator(unittest.TestCase):
    def test_addition(self):
        calc = Calculator()
        result = calc.add(2, 3)
        self.assertEqual(result, 5, "Addition result should be 5")

if __name__ == '__main__':
    unittest.main()
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test startsTesting framework initializes the test runner-PASS
2Creates Calculator instanceCalculator object ready for use-PASS
3Calls add method with inputs 2 and 3Calculator processes addition-PASS
4Checks if result equals 5Result is 5self.assertEqual(result, 5)PASS
5Test endsTest runner reports success-PASS
Failure Scenario
Failing Condition: The add method returns incorrect sum, e.g., 4 instead of 5
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify in this example?
AThat the test framework runs without errors
BThat the add method returns the correct sum
CThat the Calculator class can be created
DThat the add method returns a string
Key Result
Always write tests that check the expected behavior clearly, so bugs can be found early and fixed easily.