From the course: Unit Testing in Python

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Solution: Adding test coverage

Solution: Adding test coverage - Python Tutorial

From the course: Unit Testing in Python

Solution: Adding test coverage

(upbeat music) - [Instructor] When solving this challenge, it's important to take time to see which functions are called directly and indirectly by the test suite. After systematically reading our current test file and comparing it to the source code, we can see that one of the methods without test coverage is the delete activity function on line 40. After ascertaining this, we can switch back to the test suite and write a function as follows: on line 47, I've added a test delete activity function. It first loads the fitness tracker and uses the get activities method on line 50 and 51 to check that we have one activity to start with. We then run the deletion on line 47 after teasing out the appropriate values to pass to this function, and then on line 59, we make a final check that we expect for there to be no activities left in our tracker. If you're up for an additional challenge, try adding validation to the delete function. It should guard against processing a deletion for data…

Contents