From the course: Unit Testing and Test Driven Development in Python

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Setup and first test case

Setup and first test case

- [Instructor] I've created a new project in PyCharm called Checkout, and using Python 3 virtual environment, I set up for PyTest. I already have a simple unit test and a PyTest run configuration set up to verify the product is ready to go. In the right-hand window, I have a to-do list with all the test cases that I know at this point, and they're ordered starting with the simplest test case first. So now I should be ready to start the test-driven development loop of Red/Green/Refactor. You always start in the red phase. So the first thing I need to do is implement a failing unit test. The first test case is to simply verify that I can create an instance of the new Checkout class. I'm going to update the simple test case I have now to do that. I immediately get warnings from the IDE that the Checkout reference cannot be resolved as it doesn't exist yet. This meets the requirement of having a failing unit test, so I'll go ahead and transition to the green phase and make this pass. I'll…

Contents