0
0
Testing Fundamentalstesting~10 mins

Test automation pyramid in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test simulates the test automation pyramid by running three types of tests: unit, integration, and UI. It verifies that each test level passes successfully, showing the pyramid's principle of many fast unit tests, fewer integration tests, and even fewer UI tests.

Test Code - unittest
Testing Fundamentals
import unittest

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

class TestCalculator(unittest.TestCase):
    # Unit test
    def test_add_unit(self):
        calc = Calculator()
        self.assertEqual(calc.add(2, 3), 5)

    # Integration test (simulated)
    def test_add_integration(self):
        calc = Calculator()
        result = calc.add(10, 20)
        self.assertEqual(result, 30)

    # UI test (simulated)
    def test_add_ui(self):
        # Simulate UI input and output
        input1 = 7
        input2 = 8
        calc = Calculator()
        output = calc.add(input1, input2)
        self.assertEqual(output, 15)

if __name__ == '__main__':
    unittest.main()
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test starts - unittest framework initializesTest runner ready to execute tests-PASS
2Runs unit test test_add_unit: creates Calculator instance and calls add(2,3)Calculator instance created, add method called with inputs 2 and 3Check if result equals 5PASS
3Runs integration test test_add_integration: calls add(10,20)Calculator instance used, add method called with inputs 10 and 20Check if result equals 30PASS
4Runs UI test test_add_ui: simulates UI inputs 7 and 8, calls addSimulated UI inputs processed, add method called with 7 and 8Check if output equals 15PASS
5All tests completedTest report generated showing 3 tests passed-PASS
Failure Scenario
Failing Condition: If the add method returns incorrect sum in any test
Execution Trace Quiz - 3 Questions
Test your understanding
Which test type in the automation pyramid is the fastest and most numerous?
AUnit tests
BIntegration tests
CUI tests
DManual tests
Key Result
The test automation pyramid encourages many fast unit tests, fewer integration tests, and minimal UI tests to balance speed and coverage effectively.