From the course: Unit Testing in Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Reading tests to surmise behavior

Reading tests to surmise behavior - Python Tutorial

From the course: Unit Testing in Python

Start my 1-month free trial

Reading tests to surmise behavior

- [Instructor] The great thing about test-driven development with pytest is that it fosters shared practices for test setup that allows us to quickly gain information. We can use this to our advantage to understand the source code by viewing that behavior in the test suite first. In this video we will take a look at a written test suite and try to surmise the functionality of the code. Only once we have a few key guesses will we turn to the source code to validate our assumptions. While this is not a rule for understanding the behavior of a system, this is a great tactic for understanding how the code will be used in practice. In the test_fitness_log.py file, we have a test suite that focuses on a fitness tracker. First, a test fixture called create tracker is being used to instantiate the fitness tracker on line eight. The tracker then uses a method called log_activity on line 13 to add an activity called run with a start and…

Contents