Unit Testing with Python

Unit Testing with Python
Unit Testing with Python
English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 2h 49m | 490 MB

Unit testing is a great way to foster quality and enhance collaboration with other developers. Learn to write unit tests in good style using popular frameworks like unittest and pytest.

Once you’ve learned the basics of the Python language and started building programs, you will soon realize a need for some automated tests to make sure everything you’ve built keeps on working as you (and other developers) extend and improve it. In this course, Unit Testing with Python, you will learn foundational knowledge in unit testing. First, you will discover how to write and run tests using the ‘unittest’ framework, and some theory about how to design good test cases. Next, you will explore other popular testing frameworks in Python – pytest and doctest. Finally, you will examine how to use test doubles effectively, and techniques for parameterized testing and measuring test coverage. When you’re finished with this course, you will have the skills and knowledge of writing unit tests needed to be confident adding tests for the code you write, and sharing those tests with other developers.

Table of Contents

Course Overview
1 Course Overview

Unit Test Fundamentals
2 What Is a Unit Test
3 First Example Unit Test
4 Explanation of ‘Test Case’ and ‘Test Runner’
5 Exception Checking with assertRaises & Explaination of ‘Test Suite’
6 Skipping a Test Case & Explanation of ‘Test Fixture’
7 Vocabulary Summary
8 Example of Poor Unit Test Design
9 Better Design with Arrange-Act-Assert
10 Detailed Design of Arrange-Act-Assert Test Parts
11 Module Summary

Unit Testing Why and When
12 Introducing the Module Topics – Why and When
13 Unit Testing Helps You to Understand What to Build
14 Unit Testing Helps You to Document the Units
15 Unit Testing Helps You with Design
16 Unit Testing Helps You Detect Regression
17 Limitations of Unit Testing
18 Unit Testing Is Part of Your Job
19 Test-Last Process
20 Test-First Process
21 Test-Driven Development
22 Automated Build Servers and Continuous Integration
23 Module Summary

Unit Testing with pytest
24 Introducing pytest – a Popular Alternative to unittest
25 First Test Case and Failure Analysis
26 Using PyCharm’s Test Runner
27 Additional Kinds of Assertion, Including assertRaises
28 Introduction to Test Fixtures
29 Cleaning up Fixture Resources, Chaining Fixtures
30 Organzing Test Code for Larger Programs
31 Using Markers to Control Which Tests Are Run
32 Using an HTML Report Plugin & Module Summary

Testable Documentation with doctest
33 Introducing doctest – Embed Unit Tests in Your Docstrings
34 Introduction to Yatzy Example & a First doctest
35 Using a Test Runner to Execute Your Doctests
36 Interpreting Test Failures and Updating Your Docstring
37 Handling Output That Varies Using a Wildcard
38 Handling Random Numbers, Dictionaries, Floats, and Tracebacks
39 Global Options and Directives
40 Regression Testing Your Tutorial Documentation
41 Module Summary

Using Test Doubles
42 What Is a Test Double
43 Example Using a Stub
44 Creating a Stub Using unittest.Mock
45 Example Using a Fake
46 Example Using a Dummy
47 Mocks and Spies Give You a Third Kind of Assertion
48 Example Using a Spy
49 Example Using a Mock
50 Overview of All the Types of Test Double
51 Using Monkeypatching to Insert a Test Double
52 Example Using Monkeypatching to Replace a Built-in Function
53 Module Summary

Parameterized Tests & Test Coverage
54 Module Introduction
55 Example Using Parameterized Tests with pytest
56 Example Using Parameterized Tests with unittest
57 Example Measuring Test Coverage
58 Example Measuring Branch Coverage
59 Example Adding Parameterized Tests to Existing Code with Coverage
60 Tracking Coverage Trends
61 Good Uses for Coverage, and Alternatives for Assessing Test Quality
62 Module Summary