Improve the quality of your Python code with linters, code formatters, and security vulnerability scanners.
Testing helps ensure that your app will work as expected for your end users.
Software projects with high test coverage are never perfect, but it's a good initial indicator of the quality of the software. Additionally, testable code is generally a sign of a good software architecture, which is why advanced developers take testing into account throughout the entire development lifecycle.
Types of tests:
Unit tests test the functionality of an individual unit of code isolated from its dependencies. They are the first line of defense against errors and inconsistencies in your codebase. Unit testing is a fundamental part of the Test-Driven Development (TDD) process.
Unit testing improves the maintainability of your code.
Maintainability refers to making bug fixes or enhancements to your code or to another developer needing to update your code at some point in the future.
Unit testing should be combined with a Continuous Integration (CI) process to ensure that your unit tests are constantly executing, ideally on each commit to your repository. A solid suite of unit tests can be critical to catching defects quickly and early in the development process before your end users come across them in production.
The testing-related articles and tutorials on TestDriven teach how to use pytest for unit and integration tests and Cypress for end-to-end tests. You’ll learn best practices and techniques to follow when testing your Python applications as well.
Latest Posts (14)
Interested in how TDD works? This guide walks you through the process, using modern tools and techniques, from start to finish.
Build a CRUD app with FastAPI and GraphQL.
This article looks at some tools and techniques that help make testing in Python easier.
How property-based testing via Hypothesis and Schemathesis can be used to test FastAPI
This articles serves as a guide to testing Flask applications with pytest.
Looks at an example of how Test-Driven Development improves code quality.
In the following tutorial, we walk you through the BDD development cycle by programming an example feature using Django and Aloe.
This post looks at how to set up automated performance tests to uncover and prevent inefficient database queries.
This tutorial serves as a guide for unit testing Vue components.
This post shows how to distribute automated tests with Selenium Grid and Docker Swarm. We'll also look at how to run tests against a number of browsers and automate the provisioning and deprovisioning of machines to keep costs down.
In the following tutorial, we walk you through configuring Cypress to run tests in parallel with CircleCI.
This post looks at how to introduce Cypress into your test-driven development workflow.
This post details how to add end-to-end tests to an Angular app with Cypress and Docker.