TDD — 5 IDE Helpers to Make Development Easier

1) Creating Tests

First, we have a look at creating tests, because this is the starting point in TDD. ⌘ + n (Mac) or Alt + insert (Linux, Windows) are our friends here and offer us a generator for “Test Method”:

2) Creating Classes

TDD is not only about testing but also designing a system. We think of a unit (here class) and want to get it into our test quickly to see how it looks like. This helps us to think about the interfaces and parameters. In our example we want to create a shopping cart and our idea is to have something like a factory to do that:

3) Creating methods on classes

As soon as we have classes we can decide about which behaviour the class should offer. We went for create and use Alt + Enter again to add this method into the ShoppingCartFactory class:

4) Introduce local variable

Another Alt + Enter → Create Class on the red word above gave us a ShoppingCart class. Our test is green but it does not do much yet:

5) Add as parameter

On the ShoppingCart we have a Customer. It’s probably a good idea if the ShoppingCartFactory adds this customer to the object during creation. That means create should probably have a parameter of type Customer. So, let’s continue designing from the test’s perspective:


Looking from a test’s perspective (client’s perspective) onto our modules and classes helps us to design our components “user-friendly”. Most IDEs offer shortcuts to get your ideas into running code quickly. Like that you can concentrate on the more difficult tasks, e.g. thinking about the design of your code.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store