0
0
Testing Fundamentalstesting~8 mins

Smoke testing and sanity testing in Testing Fundamentals - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Smoke testing and sanity testing
Folder Structure
  smoke_sanity_tests_project/
  ├── tests/
  │   ├── smoke/
  │   │   ├── test_login_smoke.py
  │   │   └── test_checkout_smoke.py
  │   ├── sanity/
  │   │   ├── test_payment_sanity.py
  │   │   └── test_profile_update_sanity.py
  │   └── __init__.py
  ├── pages/
  │   ├── login_page.py
  │   ├── checkout_page.py
  │   ├── payment_page.py
  │   └── profile_page.py
  ├── utils/
  │   ├── helpers.py
  │   └── data_loader.py
  ├── config/
  │   ├── config.yaml
  │   └── env_variables.py
  ├── reports/
  │   └── latest_report.html
  ├── conftest.py
  └── pytest.ini
  
Test Framework Layers
  • Test Layer: Contains smoke and sanity test scripts organized by test type. These tests quickly check critical features (smoke) or verify specific bug fixes or functionality (sanity).
  • Page Object Layer: Encapsulates UI elements and actions for pages like login, checkout, payment, and profile. This keeps tests clean and reusable.
  • Utility Layer: Helper functions for common tasks like data loading, waiting, or logging.
  • Configuration Layer: Holds environment settings, browser options, and credentials to run tests in different setups.
  • Reporting Layer: Generates test execution reports and stores them for review.
Configuration Patterns

Use a config.yaml file to store environment URLs, browser types, and credentials. For example:

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

Load these settings in env_variables.py and use fixtures in conftest.py to pass them to tests. This allows running smoke or sanity tests on different environments easily.

Test Reporting and CI/CD Integration
  • Use pytest's built-in reporting or plugins like pytest-html to generate clear HTML reports showing which smoke and sanity tests passed or failed.
  • Store reports in the reports/ folder for easy access.
  • Integrate tests into CI/CD pipelines (e.g., GitHub Actions, Jenkins) to run smoke tests automatically on every build and sanity tests after bug fixes.
  • Fail the build if smoke tests fail to prevent broken code from progressing.
Best Practices
  1. Keep smoke tests broad but shallow: Quickly check main features to catch major issues early.
  2. Keep sanity tests narrow and deep: Focus on verifying specific fixes or functionality after changes.
  3. Organize tests by type: Separate smoke and sanity tests in folders for clarity and easy execution.
  4. Use page objects: Avoid duplicating UI code and make maintenance easier.
  5. Automate test runs in CI/CD: Ensure tests run regularly without manual effort.
Self Check

Where in this folder structure would you add a new smoke test for the "Search" feature?

Key Result
Organize smoke and sanity tests separately with clear layers for pages, utilities, config, and reporting to enable fast, reliable checks of critical and specific features.