TDD Of ShoppingCart

 

Over the last few months, I’ve published blog articles on developing a ShoppingCart class applying TDD. These articles came out every so often. I recently realised that it’s hard to follow the thinking behind the TDD development process without readily seeing previous write-ups. So, I’ve gone through the collection of TDD blogs developing the ShoppingCart class and listed them here in the correct order. I’ve provided a short outline of each blog.

ShoppingCart Construction:

  1. A Little TDD     We have no ShoppingCart class. How do we write a test to create it?
  2. The 3 Rules Of TDD     Explains the three rules of TDD. When constructing a new ShoppingCart instance, it costs $0.
  3. TDD Continued    Let’s ensure a new ShoppingCart instance has no contents and is empty.

ShoppingCart Add() method:

  1. Adding A Method With TDD    We want to put items into ShoppingCart. Let’s write tests to create an Add() method.
  2. Adding A Parameter To A Method With TDD    Add() does not have any parameters. Here we discover how to use tests to force a Product parameter on ShoppingCart.
  3. TDD – Validate Shopping Cart Quantity    When adding products into a ShoppingCart, we must also specify a quantity. What if the quantity is 0?
  4. TDD – Add Exception Message    Here we flesh out a validation exception with an exception message – the TDD way.
  5. TDD – Invalid ShoppingCart Quantity    We can’t put -2 number of items into a ShoppingCart. Let’s write some tests to handle this case.
  6. TDD – Invalid ShoppingCart Quantity (Part 2)    In this blog, we are modifying the negative quantity validation from a specific number to any negative number.
  7. TDD – Invalid ShoppingCart Quantity (Part 3 – Refactor)    Here we are simplifying the ShoppingCart invalid quantity validation.

 

As I publish more blogs on the further TDD development of ShoppingCart, I’ll add them to the list.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply