0
0
Testing Fundamentalstesting~8 mins

Test automation pyramid in Testing Fundamentals - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Test automation pyramid
Test Automation Pyramid: Folder Structure
  test-automation-project/
  ├── unit/
  │   ├── test_module1.py
  │   └── test_module2.py
  ├── integration/
  │   ├── test_integration1.py
  │   └── test_integration2.py
  ├── e2e/
  │   ├── test_login_flow.py
  │   └── test_checkout_flow.py
  ├── utils/
  │   ├── helpers.py
  │   └── fixtures.py
  ├── config/
  │   ├── config.yaml
  │   └── env_variables.py
  ├── reports/
  │   └── latest_report.html
  └── README.md
  
Test Automation Pyramid: Framework Layers
  • Unit Tests Layer: Small, fast tests for individual functions or methods. Usually located in unit/.
  • Integration Tests Layer: Tests that check how different parts work together. Found in integration/.
  • End-to-End (E2E) Tests Layer: Tests that simulate real user scenarios from start to finish. Stored in e2e/.
  • Utilities Layer: Helper functions, test data, and fixtures to support tests. Located in utils/.
  • Configuration Layer: Settings for environments, credentials, and test parameters. Found in config/.
Configuration Patterns

Use a config.yaml or similar file to store environment URLs, credentials, and browser settings.

Example config.yaml content:

  environments:
    dev:
      url: "https://dev.example.com"
      browser: "chrome"
    staging:
      url: "https://staging.example.com"
      browser: "firefox"
  credentials:
    username: "testuser"
    password: "password123"
  

Load this config in tests to run against different environments without changing code.

Test Reporting and CI/CD Integration
  • Generate HTML or XML reports after test runs, saved in reports/.
  • Integrate with CI/CD tools (like Jenkins, GitHub Actions) to run tests automatically on code changes.
  • Fail the build if critical tests fail, ensuring quality gates.
  • Send test reports via email or messaging tools for team visibility.
Best Practices for Test Automation Pyramid
  1. Test Fast at the Bottom: Write many unit tests because they run quickly and catch bugs early.
  2. Limit E2E Tests: Keep end-to-end tests few and focused since they are slower and more fragile.
  3. Clear Separation: Organize tests by type (unit, integration, e2e) to keep framework clean and maintainable.
  4. Reusable Utilities: Use helper functions and fixtures to avoid repeating code across tests.
  5. Configurable Environments: Use config files to easily switch between testing environments without code changes.
Self Check

Where in this folder structure would you add a new test that checks how the login page works with the database?

Hint: It is not a simple unit test, but it is not a full user flow either.

Key Result
Organize tests in layers: many fast unit tests at the base, fewer integration tests in the middle, and few slow end-to-end tests at the top.