Skip to content

Execution Flow

Execution Flow

  1. Plugin Configuration (pytest_configure)
  2. Load OpenAPI specification from the provided URL
  3. Validate spec completeness and quality
  4. Store configuration for dynamic test generation

  5. Test Collection (pytest_collection_modifyitems)

  6. Dynamically inject OpenAPI test items into pytest's collection
  7. Iterate over all paths and HTTP methods in the OpenAPI spec
  8. Generate test cases from examples and schemas
  9. Create individual pytest.Function items for each test case
  10. Each test appears as .::test_openapi[METHOD /path [origin-N]]
  11. Add items to pytest's test collection

  12. Collection Finish (pytest_collection_finish)

  13. Print summary of created test items:

    • Number of items from OpenAPI examples
    • Number of items generated from schemas
  14. Test Execution (pytest's normal flow)

  15. pytest runs each dynamically created test item
  16. For each test: generate request payload, execute HTTP request
  17. Compare response to contract (example or schema)
  18. pytest reports pass/fail for each test item
  19. In verbose modes (-vv, -vvv), print request/response details

  20. Report Generation (pytest_sessionfinish)

  21. Compile all test results
  22. Write detailed markdown report to file (if configured)
  23. Display report location message

This integration with pytest's standard flow means OpenAPI tests appear alongside your regular tests in the pytest output and benefit from pytest's features (parallel execution, reporting, etc.).