
Explore Python unit testing fundamentals, including terminology and test design, and learn to design good test cases while avoiding bad ones, using the built-in unit test module.
Follow recommendations and requirements to maximize learning in Python unit testing fundamentals, including a basic Python foundation and a hands-on development environment with a preferred IDE.
Discover why unit testing matters in Python, a language easy to learn with open source libraries, and learn how writing tests with unittest and pytest saves development time.
Understand what unit testing is and its place among integration and user acceptance testing. Learn to test a method with multiple cases using unittest or pytest.
List and compare unit testing frameworks, including the built-in unittest module, pytest, and nose, and explain installation needs as we use unittest to learn unit testing.
Learn unit testing terminology, including test case, test suite, test runner, unit under test, and test fixture. Explore setup and teardown concepts and their use in testing.
Write and run your first unit test with the unittest module, define a test class and methods, and verify calculator functions with assert equal using python -m unittest.
Write and run unit tests for a simple class using unittest. Import the module, instantiate the class with two numbers, and assert expected results.
Learn to run Python unit tests through IDE configurations, right-click options, and terminal commands, including running specific tests, entire classes, or folders, with verbose output.
Explore the unittest documentation to understand core concepts like test, fixture, test case, suite, and test run, along with assertions and command line options.
Learn to structure Python unit tests with unittest and pytest across multiple test classes and files, using descriptive test names, test discovery, and proper test configuration for calculator scenarios.
Learn how to skip or ignore unit test cases in the unittest framework using the skip annotation, understand its impact on test results, and document the reasons for skipping.
Document and use setup and tear down methods to prepare and clean test fixtures for Python unit tests, showing how unittest and pytest manage before and after each test.
Discover how to create and run a test suite, load test cases from modules or classes, use a test loader and runner, and interpret detailed results.
Explore test discovery in Python unit testing: organize tests as test cases, ensure methods start with test, and use discovery to automatically discover and run relevant tests.
Learn how to handle known errors in unit testing by using context managers and assert raises to capture type errors when mixing int and string, ensuring tests pass.
Adopt best practices for readable, deterministic unit tests with no interdependencies, aligning with test-driven development and automated CI tools; then review and refactor existing test cases for clarity and coverage.
Refactor unit tests with versioned iterations, introducing a test fixture via setup to create a car object. Improve assertions and naming to cover speed, acceleration, seating, and features.
Explore the fundamentals of unit testing, learn key terminology, and design professional test cases that resemble production code. Discover annotating tests and generating HTML test results.
Explore the module overview of Python unit testing with unittest and pytest, including how pytest identifies tests and skips them. Learn parameterization and fixtures to categorize tests.
Install pytest in PyCharm by configuring a virtual environment, selecting the Python interpreter, and installing pytest; verify by importing pytest.
Explore the pytest documentation on python.org to learn how to install pytest with pip, verify the version, and navigate the docs for deep insights while writing tests.
Write your first pytest test by importing the module and asserting functions such as get a number, get double, and get a list. Run pytest to observe results.
Explore sample Python apps to practice unit testing with unittest and pytest, reviewing a calculator class and an employee module with properties, validations, bonuses, retirement contributions, and compensation calculations.
Write three unit tests for the employee class using unittest or pytest to verify the base annual salary remains within the 40k–120k range and returns zero for out-of-range values.
Learn to write python tests with assertions using unittest and pytest, handle division by zero errors with context managers, and validate exception messages and dictionary data.
Discover how pytest and unittest identify tests, with modules and functions named starting or ending with test, and customize behavior using pytest.ini with python_files, python_classes, and python_functions.
Learn to skip tests with pytest markers, including unconditional and conditional skips, xfail expectations, skip if conditions, and documenting reasons and version-based skips.
Parameterize test functions in unittest and pytest by supplying multiple input sets with markers, enabling each value combination to run against the function and verify an expected result.
Learn to implement test fixtures that initialize a calculator for score addition. Wire fixtures to test functions for score difference and multiply, and organize them module-wide.
Define and use custom pytest markers to categorize tests, such as both_positive and one_negative, register them to avoid warnings, and run selective tests with -m against a calculator class.
Explore this module overview for Python unit testing fundamentals, including running a subset of test cases, applying thresholds, identifying slow tests, and parallel execution with three workers.
Learn to run tests in PyCharm by right-clicking a module to run all tests or a single test function, and create configurations to run all tests.
Learn to run tests in the terminal with pytest, activate the virtual environment, and filter tests by markers like smoke test and both_positive from the project root.
Learn how to run a subset of tests in Python unit testing using markers (-m) and the -k option, selecting by marker names or test function names.
Learn how to stop test execution after a set number of failures using the maxfail option, illustrated by running tests that halt after the second failure for quick review.
Identify and report slow test cases by measuring each test duration, surface the top three slowest tests, and investigate why they run slowly.
Discover how to run Python unit tests in parallel with pytest-xdist, install the package, configure workers with -n, and achieve substantial time savings for non-dependent unit tests.
Learn how to generate results in XML and HTML formats, understand accessible and original reporting formats, and publish team reports for online access.
Learn to generate test results in XML or Excel format from Python unit tests using a simple command, enabling easy sharing with automation systems.
Learn to generate readable HTML test reports from unit test results by installing a reporting package, running tests to produce HTML output, and sharing results with the team.
You might be wondering what this course is about? Well, this course is all about Unit Testing with Python and how it can help you become better at the art of programming. In other words, this course will teach you how to use Unit Testing to improve code quality and support future development.
Unit tests should provide immediate value in terms of reduced debugging and better design, which is why it’s a skill that should be mastered by all python programmers, regardless of their career path. This course will show you how to write unit tests for your code in Python! The course is designed to be practical with hands-on examples you can use right away.
Good unit tests should provide immediate value in terms of reduced debugging and better design, and increase your confidence in the code.
A lot of people can learn to write unit tests with this course, regardless of their career path. To help you get started, you get a 30-day money back guarantee on your purchase
You will learn:
Understand the terms: Test Case, Test Suite, Test Runner, Unit Under Test and Test Fixture.
Write Unit Tests
Running Unit Tests
Writing Test Suite
Skipping and Ignoring Unit Tests
Setup and TearDown
Test Discovery
Handling Known Errors
Best Practices