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.

Add items, add items prices, and calculate current total

Add items, add items prices, and calculate current total - Python Tutorial

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

Add items, add items prices, and calculate current total

- [Instructor] In this lecture, I'll be implementing the add item prices and items in calculate total test cases. I'm in the red phase of the TDD loop, so I need to create the test for the CanAddItemPrice test case, which will simply instantiate the Checkout class and try to call an addItemPrice method that will pass in the item string and the item price. Okay, I've got a failing unit test with a red phase is complete, and now I need to enter the green phase and make this test pass. And I need to make it pass with the simplest implementation I can come up with. In this case, I just need to implement, an empty addItemPrice method to Checkout. I've done that, and my unit test is now passing, and I can enter the refactoring phase. Is there anything to refactor here? The Checkout instantiation is duplicated in both of my tests. I don't think the first test is necessary anymore as I'm validating I can instantiate an instance of Checkout in the canAddItemPrice test. I'm going to go ahead…

Contents