2024-09-28 –, 4F Track4
Maintaining code quality in a growing codebase is challenging. We faced issues like increased test suite execution time, slow test startups, and coverage reporting overhead. By leveraging open-source tools, we significantly enhanced testing efficiency. We utilized pytest-xdist for parallel test execution, reducing test times and accelerating development. Optimizing test startup with Docker and Kubernetes for CI, and pytest-hot-reloading for local development, improved productivity. Customizing coverage tools to target updated files minimized overhead. This resulted in an 8000-case increase in test volume, 85% test coverage, and CI tests completing in under 15 minutes.
Outline
Overview: (5 minutes)
- Python Testing with pytest
- Test Coverage Measurement
- Local Setup
- Continuous Integration
Challenge Faced: (5 minutes)
- Large Codebase
- Test Suite Execution Time
- Slow Test Startup
- Test Coverage Reporting Overhead
Solution: (15 minutes)
- Parallel Test Execution
- Optimized Test Startup
- Efficient Test Coverage Reporting
Recap (2 minutes)
Q&A (3 minutes)
I chose this topic because managing testing in a large Python codebase is a critical yet complex challenge that many developers face. My experience in overcoming obstacles such as prolonged test execution times, slow test startups, and coverage reporting overhead has shown me the significant improvements that can be achieved with the right strategies and tools. By sharing our approach—leveraging parallel test execution, optimizing test startup, and efficient coverage reporting—I aim to help other teams enhance their testing efficiency, maintain high code quality, and boost developer productivity.
Knowledges and know-how the audience can get from your talk –By attending this talk, the audience will be equipped with actionable strategies and tools to enhance testing efficiency and maintain high code quality in large Python projects:
- Python Testing Fundamentals: Understanding the basics of testing with pytest and the importance of thorough test coverage.
- Challenges in Large Codebases: Insight into common issues like extended test suite execution times, slow test startups, and coverage reporting overhead.
- Parallel Test Execution: Techniques to reduce test times significantly by distributing tests across multiple runners using pytest-xdist.
- Optimized Test Startup: Strategies for speeding up test startup times with Docker images and Kubernetes for CI, and pytest-hot-reloading for local development.
- Efficient Test Coverage Reporting: Methods to minimize overhead by customizing coverage tools to focus on updated files only.
- Real-world Applications: Practical examples and outcomes from implementing these solutions in a large-scale codebase, showing a substantial increase in test volume and coverage, and improved CI times.
Attendees should have:
- Basic Python Syntax and Concepts: Familiarity with Python programming, including fundamental syntax and constructs.
- Understanding of Software Development Processes: Basic knowledge of development workflows, such as coding, testing, and continuous integration (CI).
Intermediate
Language of presentation –English
Language of presentation material –English