O'Reilly logo

Test-Driven Development with Mockito by Sujoy Acharya

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Applying TDD

The previous chapters, Chapter 1, Getting Familiar with TDD and Chapter 2, Refactoring – Roll the Dice, gave us an overview of TDD, refactoring, and code smells from 1000 feet. It's time to take a closer look.

Now we know that the automated unit tests are a safety net for refactoring. Unit tests are re-run with every code change; failing tests indicate that something went wrong. So, the code is monitored continuously.

In this chapter we will apply Test-Driven Development (TDD) to write testfirst code.

Understanding different test types

We write tests for anything that can break basically into an algorithm or a logic, for example, the logic of calculating service tax. But we don't write tests for obvious things that can't go ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required