0
0
Testing Fundamentalstesting~8 mins

CRUD operation verification in Testing Fundamentals - Framework Patterns

Choose your learning style9 modes available
Framework Mode - CRUD operation verification
Folder Structure
crud-verification-project/
├── tests/
│   ├── create_tests.py
│   ├── read_tests.py
│   ├── update_tests.py
│   └── delete_tests.py
├── pages/
│   └── resource_page.py
├── utils/
│   ├── api_client.py
│   └── helpers.py
├── config/
│   └── config.yaml
├── reports/
│   └── test_report.html
└── conftest.py
  
Test Framework Layers
  • Test Layer: Contains test scripts for each CRUD operation (Create, Read, Update, Delete). Each test verifies the expected behavior of the operation.
  • Page/Object Layer: Represents the resource or entity being tested. Provides methods to perform CRUD actions in a reusable way.
  • Utility Layer: Contains helper functions and API client code to interact with the system under test, such as sending HTTP requests or database queries.
  • Configuration Layer: Holds environment settings, credentials, and other configurable parameters to run tests in different setups.
Configuration Patterns

Use a config.yaml file to store environment URLs, credentials, and other settings. Load this config in tests and utilities to avoid hardcoding values.

Example config.yaml content:

environment:
  base_url: "https://api.example.com"
  username: "testuser"
  password: "securepass"
browser: "chrome"
  

Use fixtures (e.g., in conftest.py) to initialize test setup like authentication tokens or database connections before tests run.

Test Reporting and CI/CD Integration
  • Generate HTML or XML test reports after test runs to summarize passed and failed CRUD tests.
  • Integrate the test suite with a CI/CD pipeline (e.g., GitHub Actions, Jenkins) to run tests automatically on code changes.
  • Use clear test names and logs to quickly identify which CRUD operation failed and why.
Framework Design Principles
  1. Single Responsibility: Separate tests by CRUD operation for clarity and easier maintenance.
  2. Reusable Components: Use page or resource objects to avoid repeating code for CRUD actions.
  3. Data-Driven Testing: Use test data inputs to cover different scenarios for each CRUD operation.
  4. Clear Assertions: Verify both the action success and the data integrity after each CRUD operation.
  5. Environment Independence: Use configuration files and fixtures to run tests in different environments without code changes.
Self Check

Question: Where in this folder structure would you add a new test script to verify the "Update" operation for a new resource type?

Key Result
Organize CRUD tests by operation with reusable resource objects and clear configuration for maintainable verification.