Template Training

Introduction to Testing (and Continuous Integration)

In this lesson we introduce the concept of testing, how it can help to improve the accuracy of your code and how to implement it efficiently using a Python library called pytest.

Though some of this testing functionality is specific to python, the approach and principles are general and libraries/frameworks exist in most languages.

Prerequisites

In order to complete the tutorial and use the build system you should be familar with:

  • Basic understanding of Python variables and functions are a necessary prerequisite.
  • Some previous experience with the shell is expected.

Schedule

Approximate timings for the lesson:

Time Episode Description
0:00 Setup Setup
0:05 Introduction Why test?
0:10 Basics of Testing What are tests?
0:15 Assertive Defensive Programming How can we compare observed and expected values?
0:30 Revision of Functions in Scripts How can we put our new assertions into a scipt that we can run or import?
1:00 Exceptional Defensive Programming How do I handle unusual behavior while the code runs?
1:15 Unit Tests What is a unit of code?
1:30 Running Tests with pytest How do I automate my tests?
1:45 Edge and Corner Cases How do I catch all the possible errors?
2:05 Integration and Regression Tests How do we test more than a single unit of software?
2:15 Continuous Integration How can I automate running the tests on more platforms than my own?
2:40 Test Driven Development How do you make testing part of the code writing process?